SUPPORT-8836:fixes
This commit is contained in:
parent
384a97d629
commit
1a771c33f9
1 changed files with 9 additions and 12 deletions
|
|
@ -28,9 +28,9 @@ public class FileScanService {
|
||||||
File tempFile = null;
|
File tempFile = null;
|
||||||
try {
|
try {
|
||||||
tempFile = saveFile(file);
|
tempFile = saveFile(file);
|
||||||
return runKeslScan(tempFile);
|
return runKeslScan(tempFile, file.getOriginalFilename());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (IOException | InterruptedException e) {
|
||||||
throw new AvException("Error scanning file: " + file.getOriginalFilename(), e);
|
throw new AvException("Error scanning file: " + file.getOriginalFilename(), e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
@ -47,15 +47,14 @@ public class FileScanService {
|
||||||
|
|
||||||
private File saveFile(MultipartFile file) throws IOException {
|
private File saveFile(MultipartFile file) throws IOException {
|
||||||
Path uploadPath = Paths.get(uploadDirectory);
|
Path uploadPath = Paths.get(uploadDirectory);
|
||||||
if (!Files.exists(uploadPath)) {
|
Files.createDirectories(uploadPath);
|
||||||
Files.createDirectories(uploadPath);
|
Path tempFilePath = Files.createTempFile(uploadPath, "kesl-upload-", ".tmp");
|
||||||
}
|
File tempFile = tempFilePath.toFile();
|
||||||
Path tempFile = Files.createTempFile(uploadPath, "kesl-upload-", ".tmp");
|
file.transferTo(tempFile);
|
||||||
file.transferTo(tempFile.toFile());
|
return tempFile;
|
||||||
return tempFile.toFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int runKeslScan(File file) throws IOException, InterruptedException {
|
private int runKeslScan(File file, String originalFileName) throws IOException, InterruptedException {
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(KESL_CONTROL, KESL_SCAN,
|
ProcessBuilder processBuilder = new ProcessBuilder(KESL_CONTROL, KESL_SCAN,
|
||||||
file.getAbsolutePath()
|
file.getAbsolutePath()
|
||||||
);
|
);
|
||||||
|
|
@ -65,8 +64,6 @@ public class FileScanService {
|
||||||
if (exitCode == 0 || exitCode == 72) {
|
if (exitCode == 0 || exitCode == 72) {
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
else {
|
throw new AvException("KESL error scanning file: " + originalFileName + ", exit code: " + exitCode);
|
||||||
throw new AvException("KESL error, exit code: " + exitCode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue