From a56095dc48a6c32af24f35d285171162ecf99b50 Mon Sep 17 00:00:00 2001 From: DavidMarkMadison Date: Fri, 11 Dec 2020 17:18:51 -0600 Subject: [PATCH 1/2] Update AmazonS3FileStorage.java Is there some reason the FileDescriptor.id field (a UUID) is used to store the file on amazon? I understand that somehow the file name may be blank, but it is a required field for FileDescriptor. I modified the getFileName() to use FileDescriptor.name as long as it is not blank. If it is, resort to the UUID. --- .../addon/cubaaws/s3/AmazonS3FileStorage.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java b/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java index 7e0b0e3..5b38067 100644 --- a/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java +++ b/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java @@ -220,10 +220,21 @@ protected String getStorageDir(Date createDate) { } protected String getFileName(FileDescriptor fileDescriptor) { - if (StringUtils.isNotBlank(fileDescriptor.getExtension())) { - return fileDescriptor.getId().toString() + "." + fileDescriptor.getExtension(); - } else { - return fileDescriptor.getId().toString(); + if (StringUtils.isNotBlank(fileDescriptor.getName()) { + if (StringUtils.isNotBlank(fileDescriptor.getExtension())) { + return fileDescriptor.getName() + "." + fileDescriptor.getExtension(); + } + else { + return fileDescriptor.getName(); + } + } + else { + if (StringUtils.isNotBlank(fileDescriptor.getExtension())) { + return fileDescriptor.getId().toString() + "." + fileDescriptor.getExtension(); + } + else { + return fileDescriptor.getId().toString(); + } } } @@ -242,4 +253,4 @@ protected String getSecretAccessKey() { protected String getAccessKey() { return amazonS3Config.getAccessKey(); } -} \ No newline at end of file +} From 06ce8d1e00749fccf66778ab5d79573b5058312c Mon Sep 17 00:00:00 2001 From: DavidMarkMadison Date: Fri, 11 Dec 2020 17:23:34 -0600 Subject: [PATCH 2/2] Missed a closing parenthesis Inline edited this and the realized I missed a closing p... --- .../src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java b/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java index 5b38067..9bece25 100644 --- a/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java +++ b/modules/core/src/com/haulmont/addon/cubaaws/s3/AmazonS3FileStorage.java @@ -220,7 +220,7 @@ protected String getStorageDir(Date createDate) { } protected String getFileName(FileDescriptor fileDescriptor) { - if (StringUtils.isNotBlank(fileDescriptor.getName()) { + if (StringUtils.isNotBlank(fileDescriptor.getName())) { if (StringUtils.isNotBlank(fileDescriptor.getExtension())) { return fileDescriptor.getName() + "." + fileDescriptor.getExtension(); }