Skip to content

Commit 6fef731

Browse files
committed
Ensure original filename is provided for log attachments. Closes #1684
1 parent 7341cc8 commit 6fef731

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/java/CdbWebPortal/src/java/gov/anl/aps/cdb/portal/model/jsf/beans/LogAttachmentUploadBean.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public void upload(UploadedFile uploadedFile) {
5050
Path uploadDirPath;
5151
try {
5252
if (uploadedFile != null && !uploadedFile.getFileName().isEmpty()) {
53-
String uploadedExtension = FileUtility.getFileExtension(uploadedFile.getFileName());
53+
String fileName = uploadedFile.getFileName();
54+
String uploadedExtension = FileUtility.getFileExtension(fileName);
5455

5556
uploadDirPath = Paths.get(StorageUtility.getFileSystemLogAttachmentsDirectory());
5657
logger.debug("Using log attachments directory: " + uploadDirPath.toString());
@@ -66,13 +67,14 @@ public void upload(UploadedFile uploadedFile) {
6667
logger.debug("Saved file: " + originalFile.toPath());
6768
Attachment attachment = new Attachment();
6869
attachment.setName(originalFile.getName());
70+
attachment.setOriginalFilename(fileName);
6971
List<Attachment> attachmentList = logEntry.getAttachmentList();
7072
if (attachmentList == null) {
7173
attachmentList = new ArrayList<>();
7274
logEntry.setAttachmentList(attachmentList);
7375
}
7476
attachmentList.add(attachment);
75-
SessionUtility.addInfoMessage("Success", "Uploaded file " + uploadedFile.getFileName() + ".");
77+
SessionUtility.addInfoMessage("Success", "Uploaded file " + fileName + ".");
7678
}
7779
} catch (IOException ex) {
7880
logger.error(ex);

0 commit comments

Comments
 (0)