diff --git a/src/main/java/org/craftercms/studio/impl/v2/service/aws/s3/AwsS3ServiceImpl.java b/src/main/java/org/craftercms/studio/impl/v2/service/aws/s3/AwsS3ServiceImpl.java index a77f8bb06c..188ffa2f2e 100644 --- a/src/main/java/org/craftercms/studio/impl/v2/service/aws/s3/AwsS3ServiceImpl.java +++ b/src/main/java/org/craftercms/studio/impl/v2/service/aws/s3/AwsS3ServiceImpl.java @@ -123,7 +123,7 @@ public S3Item uploadItem(@SiteId String siteId, AwsUtils.uploadStream(inputBucket, fullKey, s3Client, partSize, filename, content); - return new S3Item(filename, createUrl(profileId, relativeKey), false, inputBucket); + return new S3Item(filename, createUrl(profileId, relativeKey), false, inputBucket, profile.getPrefix()); } /** @@ -158,7 +158,7 @@ public List listItems(@SiteId String siteId, result.getCommonPrefixes().stream() .map(p -> { String relativeKey = StringUtils.removeStart(p, profile.getPrefix()); - return new S3Item(StringUtils.removeEnd(relativeKey, delimiter), relativeKey, true, profile.getBucketName()); + return new S3Item(StringUtils.removeEnd(relativeKey, delimiter), relativeKey, true, profile.getBucketName(), profile.getPrefix()); }) .forEach(items::add); @@ -167,7 +167,7 @@ public List listItems(@SiteId String siteId, MimeType.valueOf(StudioUtils.getMimeType(o.getKey())).isCompatibleWith(filerType)) .map(o -> { String relativeKey = StringUtils.removeStart(o.getKey(), profile.getPrefix()); - return new S3Item(relativeKey, createUrl(profileId, relativeKey), false, profile.getBucketName()); + return new S3Item(relativeKey, createUrl(profileId, relativeKey), false, profile.getBucketName(), profile.getPrefix()); }) .forEach(items::add); diff --git a/src/main/java/org/craftercms/studio/model/aws/s3/S3Item.java b/src/main/java/org/craftercms/studio/model/aws/s3/S3Item.java index a4d9687b49..15dd9987fd 100644 --- a/src/main/java/org/craftercms/studio/model/aws/s3/S3Item.java +++ b/src/main/java/org/craftercms/studio/model/aws/s3/S3Item.java @@ -42,11 +42,17 @@ public class S3Item { */ protected String bucketName; - public S3Item(final String name, final String url, final boolean folder, final String bucketName) { + /** + * The prefix of the S3 bucket (if any). + */ + protected String prefix; + + public S3Item(final String name, final String url, final boolean folder, final String bucketName, final String prefix) { this.name = name; this.url = url; this.folder = folder; this.bucketName = bucketName; + this.prefix = prefix; } public String getName() { @@ -81,4 +87,11 @@ public void setBucketName(final String bucketName) { this.bucketName = bucketName; } + public String getPrefix() { + return prefix; + } + + public void setPrefix(final String prefix) { + this.prefix = prefix; + } }