标注结果和标注结果归档优化
This commit is contained in:
@@ -68,23 +68,24 @@ public class SourceResourceController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "下载图片资源")
|
||||
@Operation(summary = "下载资源")
|
||||
@GetMapping("/{id}/download")
|
||||
public ResponseEntity<byte[]> downloadImage(
|
||||
public ResponseEntity<byte[]> downloadResource(
|
||||
@Parameter(description = "资源ID", example = "191000000000000101")
|
||||
@PathVariable Long id
|
||||
) {
|
||||
var currentUser = UserContext.requireUser();
|
||||
byte[] imageData = sourceResourceService.downloadImage(currentUser, id);
|
||||
byte[] resourceData = sourceResourceService.downloadResource(currentUser, id);
|
||||
|
||||
// 获取资源信息以确定Content-Type
|
||||
SourceResource resource = sourceResourceService.getResourceEntity(id);
|
||||
String contentType = sourceResourceService.getImageContentType(resource);
|
||||
String contentType = sourceResourceService.getContentType(resource);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_TYPE, contentType)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + resource.getResourceName() + "\"")
|
||||
.body(imageData);
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getResourceName() + "\"")
|
||||
.header(HttpHeaders.CONTENT_LENGTH, String.valueOf(resource.getFileSize()))
|
||||
.body(resourceData);
|
||||
}
|
||||
|
||||
// 添加新接口
|
||||
|
||||
Reference in New Issue
Block a user