1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-13 09:46:17 +00:00

keep filename in temporary file

This commit is contained in:
bgamard
2022-05-16 19:22:54 +02:00
parent dc0c20cd0c
commit 5e7f06070e
2 changed files with 10 additions and 5 deletions

View File

@@ -113,10 +113,12 @@ public class FileResource extends BaseResource {
}
// Keep unencrypted data temporary on disk
String name = fileBodyPart.getContentDisposition() != null ?
URLDecoder.decode(fileBodyPart.getContentDisposition().getFileName(), StandardCharsets.UTF_8) : null;
java.nio.file.Path unencryptedFile;
long fileSize;
try {
unencryptedFile = AppContext.getInstance().getFileService().createTemporaryFile();
unencryptedFile = AppContext.getInstance().getFileService().createTemporaryFile(name);
Files.copy(fileBodyPart.getValueAs(InputStream.class), unencryptedFile, StandardCopyOption.REPLACE_EXISTING);
fileSize = Files.size(unencryptedFile);
} catch (IOException e) {
@@ -124,8 +126,6 @@ public class FileResource extends BaseResource {
}
try {
String name = fileBodyPart.getContentDisposition() != null ?
URLDecoder.decode(fileBodyPart.getContentDisposition().getFileName(), StandardCharsets.UTF_8) : null;
String fileId = FileUtil.createFile(name, previousFileId, unencryptedFile, fileSize, documentDto == null ?
null : documentDto.getLanguage(), principal.getId(), documentId);