Skip to content

Commit

Permalink
fix: Fixing new AWS SDK v2 pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeriolino committed Nov 14, 2023
1 parent 989b140 commit e7be7d0
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ public S3Object[] list(String path) {
List<S3Object> objectSummaries = new ArrayList<>();
do {
objectListing = this.amazonS3.listObjects(listObjectsRequest.build());
objectSummaries.addAll(objectListing.contents());
listObjectsRequest.marker(objectListing.nextMarker());
List<S3Object> contents = objectListing.contents();
objectSummaries.addAll(contents);
if (objectListing.isTruncated()) {
listObjectsRequest.marker(contents.get(contents.size() - 1).key());
}
}
while (objectListing.isTruncated());

Expand All @@ -108,10 +111,13 @@ public String[] listNames(String path) {
List<String> names = new ArrayList<>();
do {
objectListing = this.amazonS3.listObjects(listObjectsRequest.build());
for (S3Object objectSummary : objectListing.contents()) {
List<S3Object> contents = objectListing.contents();
for (S3Object objectSummary : contents) {
names.add(objectSummary.key());
}
listObjectsRequest.marker(objectListing.nextMarker());
if (objectListing.isTruncated()) {
listObjectsRequest.marker(contents.get(contents.size() - 1).key());
}
}
while (objectListing.isTruncated());

Expand Down

0 comments on commit e7be7d0

Please sign in to comment.