Using Alibaba OSS Java SDK, I can only retrieve maximum 100 objects in Bucket. How to list all objects?
compile group: 'com.aliyun.oss', name: 'aliyun-sdk-oss', version: '3.9.1'
ObjectListing objectListing = ossClient.listObjects(bucketName);
int count = 1;
// Use objectListing.getObjectSummaries to obtain the descriptions of all objects.
for (OSSObjectSummary objectSummary : objectListing.getObjectSummaries()) {
System.out.println(count++ + " - " + objectSummary.getKey() + " " +
"(size = " + objectSummary.getSize() + ")");
}
Using below code, all objects from a Bucket can be listed. Reference Link.
do
{
System.out.println("**** ITERATION COUNT - " + itCount++ + "*****");
// The number of objects listed in each page is specified by the maxKeys parameter. If the object number is larger than the specified value, other files are listed in another page.
ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName, null, nextMarker, null, 100);
result = client.listObjects(listObjectsRequest);
for (OSSObjectSummary summary: result.getObjectSummaries())
{
System.out.println("Object Count: " + objCount++ + ", Name:" + summary.getKey());
}
nextMarker = result.getNextMarker();
} while (result.isTruncated());