What is the simplest way to get a list of all items within an S3 bucket using Java?
List s3objects = s3.listObjects(bucketName,prefix)
Try this one out
public void getObjectList(){
System.out.println("Listing objects");
ObjectListing objectListing = s3.listObjects(new ListObjectsRequest()
.withBucketName(bucketName)
.withPrefix("ads"));
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
System.out.println(" - " + objectSummary.getKey() + " " +
"(size = " + objectSummary.getSize() + ")");
}
}
You can all the objects within the bucket with specific prefix.