Creato servizio downloadFileFromRefUuid
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-09-09 15:57:47 +02:00
parent 63727411c4
commit d6ac2f00b6
2 changed files with 33 additions and 2 deletions

View File

@@ -750,6 +750,24 @@ public class EmsController {
return ResponseEntity.notFound().build();
}
@GetMapping(value = "downloadFileFromRefUuid")
public ResponseEntity<byte[]> downloadFileFromRefUuid(@RequestParam(CommonConstants.PROFILE_DB) String config,
@RequestParam() String refUuid,
@RequestParam() String fileName) throws Exception {
AttachmentDTO attached = emsServices.downloadFileFromRefUuid(refUuid, fileName);
if (attached == null) return ResponseEntity.notFound().build();
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(attached.getMimeType()))
.contentLength(attached.getFileSize())
.header(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition
.attachment()
.filename(attached.getFileName())
.build()
.toString())
.body(attached.getFileContent());
}
@RequestMapping(value = EmsRestConstants.PATH_DOWNLOAD_STB_FILE_ATTACHMENT, method = RequestMethod.GET)
public ResponseEntity<byte[]> downloadStbFileAttachmentPath(

View File

@@ -28,6 +28,7 @@ import it.integry.ems.json.ResponseJSONObjectMapper;
import it.integry.ems.media.MediaImageService;
import it.integry.ems.media.MediaVideoService;
import it.integry.ems.media.MimeTypesHandler;
import it.integry.ems.object_storage.minio.MinIOService;
import it.integry.ems.properties.EmsProperties;
import it.integry.ems.properties.EnvProperties;
import it.integry.ems.response.EsitoType;
@@ -138,6 +139,9 @@ public class EmsServices {
@Autowired
private BasicConnectionPool basicConnectionPool;
@Autowired
private MinIOService minIOService;
public EntityImportResponse<List<EntityBase>> importEntity(String type, String format, ImportRequestDTO body, boolean headless) throws Exception {
logger.debug("Starting import [Type: " + type + ", Format: " + format + "]");
String gestName = "IMPORT_" + type;
@@ -587,8 +591,6 @@ public class EmsServices {
}
public AttachmentDTO downloadStbFileAttachment(String idAttach, boolean requestThumbnail) throws Exception {
StbFilesAttached stbFilesAttached = new StbFilesAttached();
stbFilesAttached.setIdAttach(idAttach);
stbFilesAttached.setOperation(OperationType.SELECT_OBJECT);
@@ -631,6 +633,17 @@ public class EmsServices {
return null;
}
public AttachmentDTO downloadFileFromRefUuid(String refUuid, String fileName) throws Exception {
byte[] bytes = minIOService.downloadObject(refUuid, multiDBTransactionManager.getPrimaryConnection());
String mimeType = mimeTypesHandler.getContentType(fileName).toString();
return new AttachmentDTO()
.setFileContent(bytes)
.setFileSize(bytes != null ? bytes.length : 0)
.setMimeType(mimeType)
.setFileName(fileName);
}
public String createZipFromFiles(CreateZipDTO createZipDTO) throws Exception {
if (createZipDTO == null) {
throw new MissingDataException("createZipFromFiles");