Skip to content

Instantly share code, notes, and snippets.

@watchamcb
Created March 7, 2015 04:41
Show Gist options
  • Save watchamcb/5d1c92b3acb56a34b9ec to your computer and use it in GitHub Desktop.
Save watchamcb/5d1c92b3acb56a34b9ec to your computer and use it in GitHub Desktop.
AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());
ListObjectsRequest listObjectsRequest = new ListObjectsRequest()
.withBucketName(bucketName)
.withPrefix("bob")
.withEncodingType("url");
ObjectListing objectListing;
do {
objectListing = s3client.listObjects(listObjectsRequest);
for (S3ObjectSummary objectSummary :
objectListing.getObjectSummaries()) {
System.out.println( " - " + objectSummary.getKey() + " " +
"(size = " + objectSummary.getSize() + ")");
}
listObjectsRequest.setMarker(objectListing.getNextMarker());
} while (objectListing.isTruncated());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment