This commit is contained in:
@@ -524,19 +524,13 @@ public class ApiController {
|
||||
// errorData));
|
||||
// }
|
||||
|
||||
StreamingResponseBody responseBody = outputStream -> {
|
||||
try (InputStream stream = cloudStorageService.readFileFromStorage(entityResponse.getProtectedFilePath())) {
|
||||
ByteStreams.copy(stream, outputStream);
|
||||
} catch (NoSuchKeyException e) {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "File not found");
|
||||
}
|
||||
};
|
||||
byte[] bytes = cloudStorageService.readFileFromStorageBytes(entityResponse.getProtectedFilePath());
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION,
|
||||
"attachment; filename=\"" + entityResponse.getFileName() + "\"")
|
||||
.body(responseBody);
|
||||
.body(bytes);
|
||||
} catch (FileEntityNotFoundException e) {
|
||||
Map<String, Object> errorData = new HashMap<>();
|
||||
errorData.put("fileId", fileId);
|
||||
|
||||
Reference in New Issue
Block a user