I have two buckets in AWS S3. For one of the buckets, code given below returns all the file names (more than 1000) but the same code returns only 1000 file names for 2nd bucket:
ObjectListing objects = s3.listObjects("bucket.new.test");
do {
for (S3ObjectSummary objectSummary : objects.getObjectSummaries()) {
String key = objectSummary.getKey();
System.out.println(key);
}
objects = s3.listNextBatchOfObjects(objects);
} while (objects.isTruncated());
My 2nd bucket has hierarchical structure (like folder1/folder2/filename.jpg). I fixed the issue by changing my code to use addAll instead of for loop to add object one by one. This is modified code:
List<S3ObjectSummary> keyList = new ArrayList<S3ObjectSummary>(); ObjectListing object = s3.listObjects("bucket.new.test"); keyList = object.getObjectSummaries(); object = s3.listNextBatchOfObjects(object); while (object.isTruncated()){ keyList.addAll(current.getObjectSummaries()); object = s3.listNextBatchOfObjects(current); } keyList.addAll(object.getObjectSummaries());
How can I implement this in salesforce ?
Please do help
Sakshi,
For technical help please send an email to dev@webners.com
Thanks
Hai there
How can this code be implemented in salesforce. Please help.
Thanx