|
|
|
@ -99,15 +99,15 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket) |
|
|
|
|
.withPrefix(dir).withDelimiter(DELIMITER); |
|
|
|
|
ObjectListing objectListing = s3.listObjects(listObjectsRequest); |
|
|
|
|
collectFileEntry(result, objectListing); |
|
|
|
|
collectFileEntry(dir, result, objectListing); |
|
|
|
|
while (objectListing.isTruncated()) { |
|
|
|
|
objectListing = s3.listNextBatchOfObjects(objectListing); |
|
|
|
|
collectFileEntry(result, objectListing); |
|
|
|
|
collectFileEntry(dir, result, objectListing); |
|
|
|
|
} |
|
|
|
|
return result.toArray(new FineFileEntry[0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void collectFileEntry(List<FineFileEntry> result, ObjectListing objectListing) { |
|
|
|
|
private void collectFileEntry(String dir, List<FineFileEntry> result, ObjectListing objectListing) { |
|
|
|
|
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) { |
|
|
|
|
String key = summary.getKey(); |
|
|
|
|
if (!key.endsWith(DELIMITER)) { |
|
|
|
@ -115,9 +115,11 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (String prefix : objectListing.getCommonPrefixes()) { |
|
|
|
|
FineFileEntry entry = new FineFileEntry(prefix); |
|
|
|
|
entry.setDirectory(true); |
|
|
|
|
result.add(entry); |
|
|
|
|
if (StringUtils.isNotEmpty(prefix.substring(dir.length()).replaceAll(DELIMITER, StringUtils.EMPTY))) { |
|
|
|
|
FineFileEntry entry = new FineFileEntry(prefix); |
|
|
|
|
entry.setDirectory(true); |
|
|
|
|
result.add(entry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -319,7 +321,11 @@ public class S3ResourceRepository extends BaseResourceRepository {
|
|
|
|
|
result.add(key.substring(key.lastIndexOf(DELIMITER) + 1)); |
|
|
|
|
} |
|
|
|
|
for (String prefix : objectListing.getCommonPrefixes()) { |
|
|
|
|
result.add(prefix.substring(prefix.lastIndexOf(DELIMITER) + 1)); |
|
|
|
|
if (StringUtils.isNotEmpty(prefix.substring(dir.length()).replaceAll(DELIMITER, StringUtils.EMPTY))) { |
|
|
|
|
String[] arr = prefix.split(DELIMITER); |
|
|
|
|
String name = arr[arr.length - 1] + DELIMITER; |
|
|
|
|
result.add(name); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|