Solution 1.
AmazonS3 s3 = new AmazonS3Client();
ObjectListing current = s3.listObjects(new ListObjectsRequest().withBucketName("BucketName"));
List<S3ObjectSummary> keyList = current.getObjectSummaries();
ObjectListing next = s3.listNextBatchOfObjects(current);
keyList.addAll(next.getObjectSummaries());
while (next.isTruncated()) {
current=s3.listNextBatchOfObjects(next);
keyList.addAll(current.getObjectSummaries());
next = s3.listNextBatchOfObjects(current);
}
keyList.addAll(next.getObjectSummaries());
Solution 2.
List<S3ObjectSummary> keyList = new ArrayList<S3ObjectSummary>();
AmazonS3 s3 = new AmazonS3Client();
for ( S3ObjectSummary summary : S3Objects.inBucket(s3, "BucketName") ) {
keyList.add(summary);
}
No comments:
Post a Comment