dev fix file public endpoint
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-21 01:06:50 +07:00
parent 6366cbc96b
commit 9ad4830edb
2 changed files with 7 additions and 8 deletions
@@ -505,8 +505,7 @@ public class ApiController {
} }
Path filePath = Paths.get(entityResponse.getProtectedFilePath()); Path filePath = Paths.get(entityResponse.getProtectedFilePath());
File file = cloudStorageService.readFileFromStorageByPath( File file = cloudStorageService.readFileFromStorageByPath(entityResponse.getProtectedFilePath());
entityResponse.getProtectedFilePath());
long fileSize = Files.size(filePath); long fileSize = Files.size(filePath);
if (!file.exists()) { if (!file.exists()) {
@@ -63,11 +63,11 @@ public class FileController {
FileEntity fileEntity = fileRepository.findById(fileId) FileEntity fileEntity = fileRepository.findById(fileId)
.orElseThrow(() -> new FileNotFoundException("Not found: " + fileId)); .orElseThrow(() -> new FileNotFoundException("Not found: " + fileId));
Path filePath = Paths.get(fileEntity.getFilePath()); // Path filePath = Paths.get(fileEntity.getFilePath());
if (!Files.exists(filePath)) { // if (!Files.exists(filePath)) {
log.error("Not on disk: {}", fileEntity.getFilePath()); // log.error("Not on disk: {}", fileEntity.getFilePath());
return ResponseEntity.notFound().build(); // return ResponseEntity.notFound().build();
} // }
File file = cloudStorageService.readFileFromStorageByPath(fileEntity.getFilePath()); File file = cloudStorageService.readFileFromStorageByPath(fileEntity.getFilePath());
@@ -86,7 +86,7 @@ public class FileController {
return ResponseEntity.ok() return ResponseEntity.ok()
.contentType(mediaType) .contentType(mediaType)
.contentLength(Files.size(filePath)) .contentLength(file.length())
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString()) .header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString())
.header(HttpHeaders.CACHE_CONTROL, "public, max-age=3600") .header(HttpHeaders.CACHE_CONTROL, "public, max-age=3600")
.body(resource); .body(resource);