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

This commit is contained in:
2026-04-21 01:31:30 +07:00
parent 9ad4830edb
commit 7492b8aa7f
2 changed files with 1 additions and 21 deletions
@@ -504,9 +504,7 @@ public class ApiController {
errorData));
}
Path filePath = Paths.get(entityResponse.getProtectedFilePath());
File file = cloudStorageService.readFileFromStorageByPath(entityResponse.getProtectedFilePath());
long fileSize = Files.size(filePath);
if (!file.exists()) {
Map<String, Object> errorData = new HashMap<>();
@@ -518,11 +516,8 @@ public class ApiController {
errorData));
}
String contentType = determineContentType(filePath);
return ResponseEntity.ok()
.contentLength(fileSize)
.contentType(MediaType.parseMediaType(contentType))
.contentLength(file.length())
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + entityResponse.getFileName() + "\"")
.body(file);
@@ -624,13 +619,4 @@ public class ApiController {
return errorDetail;
}
private String determineContentType(Path filePath) throws IOException {
String contentType = Files.probeContentType(filePath);
if (contentType == null) {
contentType = "application/octet-stream";
}
return contentType;
}
}