Fix MultipartFile.transferTo overwrite + maxDPI default 500 (cucumber e2e bugs)
This commit is contained in:
@@ -854,7 +854,10 @@ public class ApplicationProperties {
|
||||
private Boolean enableDesktopInstallSlide;
|
||||
private Datasource datasource;
|
||||
private boolean disableSanitize;
|
||||
private int maxDPI;
|
||||
// Default mirrors settings.yml.template (maxDPI: 500). Without an explicit default this
|
||||
// primitive is 0, which makes every DPI check (dpi > maxDPI) fail with "maximum safe limit
|
||||
// of 0" when the value is not populated from settings.
|
||||
private int maxDPI = 500;
|
||||
private boolean enableUrlToPDF;
|
||||
private Html html = new Html();
|
||||
private CustomPaths customPaths = new CustomPaths();
|
||||
|
||||
@@ -60,7 +60,10 @@ public interface MultipartFile {
|
||||
|
||||
default void transferTo(Path dest) throws IOException {
|
||||
try (InputStream in = getInputStream()) {
|
||||
Files.copy(in, dest);
|
||||
// Spring's MultipartFile#transferTo overwrites an existing destination. Callers commonly
|
||||
// pass a path from Files.createTempFile(...) (which has already created an empty file),
|
||||
// so REPLACE_EXISTING is required - a plain Files.copy would throw FileAlreadyExists.
|
||||
Files.copy(in, dest, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -72,6 +72,9 @@ public class FileUploadMultipartFile implements MultipartFile {
|
||||
|
||||
@Override
|
||||
public void transferTo(Path dest) throws IOException {
|
||||
Files.copy(delegate.uploadedFile(), dest);
|
||||
// Overwrite semantics like Spring's MultipartFile#transferTo; callers often pass a
|
||||
// Files.createTempFile(...) path that already exists, so REPLACE_EXISTING is required.
|
||||
Files.copy(
|
||||
delegate.uploadedFile(), dest, java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user