Merge pull request 'fix: change methode for move upload file' (#116) from dev into master

Reviewed-on: #116
This commit is contained in:
Thibaut Valentin 2026-03-18 12:07:58 +00:00
commit d5c1273e18

View File

@ -20,6 +20,8 @@ import java.io.*;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -226,8 +228,6 @@ public class Utils {
"THREAT_DETECTED on File " + file.fileName() + " is infected: " + result.getMessage()); "THREAT_DETECTED on File " + file.fileName() + " is infected: " + result.getMessage());
} }
} }
File f = file.filePath().toFile();
System.out.println(f.exists() + " - " + f);
// File is clean - now we can safely process it // File is clean - now we can safely process it
LOGGER.infof("File is clean: %s (size=%d) (contentType=%s)", file.fileName(), file.size(), LOGGER.infof("File is clean: %s (size=%d) (contentType=%s)", file.fileName(), file.size(),
@ -252,10 +252,10 @@ public class Utils {
} }
} }
System.out.println( Path f = file.filePath();
f.exists() + " - " + f + " -> " + new File(dirFile, id + "." + detectedExtensions[0])); System.out.println(f + " -> " + new File(dirFile, id + "." + detectedExtensions[0]));
//noinspection ResultOfMethodCallIgnored Files.copy(f, new File(dirFile, id + "." + detectedExtensions[0]).toPath(),
System.out.println(f.renameTo(new File(dirFile, id + "." + detectedExtensions[0]))); StandardCopyOption.REPLACE_EXISTING);
return "ok"; return "ok";
}))); })));
} }