@@ -198,9 +198,18 @@ public class ApiController {
|
||||
}
|
||||
}
|
||||
|
||||
private List<SimilarFileDTO> processNonImageFile(FileEntity fileEntity, String authToken) {
|
||||
private List<SimilarFileDTO> processNonImageFile(FileEntity fileEntity, String authToken) throws Exception {
|
||||
List<SimilarFileDTO> results = new ArrayList<>();
|
||||
|
||||
FileEntity duplicateByHash = fileSimilarityService.findDuplicateByHash(fileEntity.getProtectedFilePath(),
|
||||
fileEntity.getMimeType(), fileEntity.getUserId());
|
||||
|
||||
if (duplicateByHash != null) {
|
||||
results.add(fileSimilarityService.buildDTO(duplicateByHash));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
File file = new File(fileEntity.getFilePath());
|
||||
FileProtector.Type type = "document".equals(fileEntity.getMimeType()) ?
|
||||
FileProtector.Type.DOC : FileProtector.Type.AUDIO;
|
||||
@@ -465,45 +474,6 @@ public class ApiController {
|
||||
}
|
||||
}
|
||||
|
||||
// @GetMapping("/protect/{fileId}")
|
||||
// public ResponseEntity<?> protect( @PathVariable(required = false) String fileId) {
|
||||
// Optional<FileEntity> optionalFileEntity = fileEntityRepository.findById(fileId);
|
||||
//
|
||||
// if (!optionalFileEntity.isPresent()) {
|
||||
// return ResponseEntity.notFound().build();
|
||||
// }
|
||||
// FileEntity fileEntity = optionalFileEntity.get();
|
||||
// FileProtector.FileInfo fileInfo = fileUtil.createFileInfo(fileEntity);
|
||||
//
|
||||
// noCopyFileService.addFile(fileInfo);
|
||||
//
|
||||
// fileEntity.setProtectionStatus(ProtectionStatus.PROCESSING);
|
||||
// fileEntityRepository.save(fileEntity);
|
||||
//
|
||||
// return ResponseEntity.ok().build();
|
||||
// }
|
||||
//
|
||||
// @GetMapping("/check/{fileId}/{type}")
|
||||
// public ResponseEntity<?> check(@PathVariable(required = false) String fileId,
|
||||
// @PathVariable(required = false) String type) {
|
||||
// Optional<FileEntity> optionalFileEntity = fileEntityRepository.findById(fileId);
|
||||
//
|
||||
// if (!optionalFileEntity.isPresent()) {
|
||||
// return ResponseEntity.notFound().build();
|
||||
// }
|
||||
//
|
||||
// FileEntity fileEntity = optionalFileEntity.get();
|
||||
//
|
||||
// Path path = Paths.get(fileEntity.getProtectedFilePath());
|
||||
//
|
||||
// File file = path.toFile();
|
||||
//
|
||||
// NoCopyCheckResult noCopyCheckResult = noCopyFileService.checkFile(file,
|
||||
// FileProtector.Type.valueOf(type.toUpperCase()));
|
||||
//
|
||||
// return ResponseEntity.ok().body(noCopyCheckResult);
|
||||
// }
|
||||
|
||||
@GetMapping("/check/file_stats")
|
||||
public ResponseEntity<?> checkFileProtectStats(@RequestHeader("Authorization") String tokenHeader) {
|
||||
String token = tokenHeader.replace("Bearer ", "");
|
||||
|
||||
Reference in New Issue
Block a user