This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user