diff --git a/src/main/java/ru/soune/nocopy/controller/ApiController.java b/src/main/java/ru/soune/nocopy/controller/ApiController.java index a2e77f2..711a530 100644 --- a/src/main/java/ru/soune/nocopy/controller/ApiController.java +++ b/src/main/java/ru/soune/nocopy/controller/ApiController.java @@ -339,10 +339,10 @@ public class ApiController { } - Path filePath = Paths.get(entityResponse.getFilePath()); - Resource resource = new UrlResource(filePath.toUri()); - + Path filePath = Paths.get(entityResponse.getProtectedFilePath()); // Resource resource = new UrlResource(filePath.toUri()); + FileSystemResource resource = new FileSystemResource(filePath); + long fileSize = Files.size(filePath); if (!resource.exists()) { Map errorData = new HashMap<>(); @@ -357,6 +357,7 @@ public class ApiController { String contentType = determineContentType(filePath); return ResponseEntity.ok() + .contentLength(fileSize) .contentType(MediaType.parseMediaType(contentType)) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + entityResponse.getOriginalFileName() + "\"")