This commit is contained in:
@@ -339,10 +339,10 @@ public class ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Path filePath = Paths.get(entityResponse.getFilePath());
|
Path filePath = Paths.get(entityResponse.getProtectedFilePath());
|
||||||
Resource resource = new UrlResource(filePath.toUri());
|
|
||||||
|
|
||||||
// Resource resource = new UrlResource(filePath.toUri());
|
// Resource resource = new UrlResource(filePath.toUri());
|
||||||
|
FileSystemResource resource = new FileSystemResource(filePath);
|
||||||
|
long fileSize = Files.size(filePath);
|
||||||
|
|
||||||
if (!resource.exists()) {
|
if (!resource.exists()) {
|
||||||
Map<String, Object> errorData = new HashMap<>();
|
Map<String, Object> errorData = new HashMap<>();
|
||||||
@@ -357,6 +357,7 @@ public class ApiController {
|
|||||||
String contentType = determineContentType(filePath);
|
String contentType = determineContentType(filePath);
|
||||||
|
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
|
.contentLength(fileSize)
|
||||||
.contentType(MediaType.parseMediaType(contentType))
|
.contentType(MediaType.parseMediaType(contentType))
|
||||||
.header(HttpHeaders.CONTENT_DISPOSITION,
|
.header(HttpHeaders.CONTENT_DISPOSITION,
|
||||||
"attachment; filename=\"" + entityResponse.getOriginalFileName() + "\"")
|
"attachment; filename=\"" + entityResponse.getOriginalFileName() + "\"")
|
||||||
|
|||||||
Reference in New Issue
Block a user