dev add test find by searchapo
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-05 03:30:15 +07:00
parent 8e716f7d20
commit e49a944b05
@@ -43,12 +43,29 @@ public class FileController {
FileEntity fileEntity = fileRepository.findById(fileId)
.orElseThrow(() -> new RuntimeException("File not found"));
if (fileEntity.getProtectionStatus() == ProtectionStatus.NOT_PROTECTED) {
throw new RuntimeException("File is not protected");
}
Resource resource = fileStorageService.loadFileAsResource(fileEntity.getFilePath());
return ResponseEntity.ok()
.contentType(new MediaType(fileEntity.getMimeType(), fileEntity.getFileExtension()))
.header(HttpHeaders.CONTENT_DISPOSITION,
"inline; filename=\"" + fileEntity.getOriginalFileName() + "\"")
.body(resource);
}
@GetMapping("/protected/{fileId}")
public ResponseEntity<Resource> getProtectedFile(
@PathVariable String fileId) throws IOException {
FileEntity fileEntity = fileRepository.findById(fileId)
.orElseThrow(() -> new RuntimeException("File not found"));
Resource resource = fileStorageService.loadFileAsResource(fileEntity.getProtectedFilePath());
if (fileEntity.getProtectionStatus() == ProtectionStatus.NOT_PROTECTED ||
fileEntity.getProtectionStatus() == ProtectionStatus.PROCESSING) {
throw new RuntimeException("File is not protected");
}
return ResponseEntity.ok()
.contentType(new MediaType(fileEntity.getMimeType(), fileEntity.getFileExtension()))
.header(HttpHeaders.CONTENT_DISPOSITION,