mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
keep filename in temporary file
This commit is contained in:
parent
dc0c20cd0c
commit
5e7f06070e
@ -69,13 +69,18 @@ public class FileService extends AbstractScheduledService {
|
||||
return Scheduler.newFixedDelaySchedule(0, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public Path createTemporaryFile() throws IOException {
|
||||
return createTemporaryFile(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a temporary file.
|
||||
*
|
||||
* @param name Wanted file name
|
||||
* @return New temporary file
|
||||
*/
|
||||
public Path createTemporaryFile() throws IOException {
|
||||
Path path = Files.createTempFile("sismics_docs", null);
|
||||
public Path createTemporaryFile(String name) throws IOException {
|
||||
Path path = Files.createTempFile("sismics_docs", name);
|
||||
referenceSet.add(new TemporaryPathReference(path, referenceQueue));
|
||||
return path;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user