Java Code Examples for com.amazonaws.services.s3.AmazonS3Client#listNextBatchOfObjects()

The following examples show how to use com.amazonaws.services.s3.AmazonS3Client#listNextBatchOfObjects() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSTestUtils.java    From aws-ant-tasks with Apache License 2.0 6 votes vote down vote up
public static void emptyAndDeleteBucket(AmazonS3Client client,
        String bucketName) {
    ObjectListing objectListing = client.listObjects(bucketName);

    while (true) {
        for (Iterator<?> iterator = objectListing.getObjectSummaries()
                .iterator(); iterator.hasNext();) {
            S3ObjectSummary objectSummary = (S3ObjectSummary) iterator
                    .next();
            client.deleteObject(bucketName, objectSummary.getKey());
        }

        if (objectListing.isTruncated()) {
            objectListing = client.listNextBatchOfObjects(objectListing);
        } else {
            break;
        }
    }
    client.deleteBucket(bucketName);
}
 
Example 2
Source File: S3ClientImpl.java    From exhibitor with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectListing listNextBatchOfObjects(ObjectListing previousObjectListing) throws Exception
{
    RefCountedClient holder = client.get();
    AmazonS3Client amazonS3Client = holder.useClient();
    try
    {
        return amazonS3Client.listNextBatchOfObjects(previousObjectListing);
    }
    finally
    {
        holder.release();
    }
}