listNextBatchOfObjects()请求对象

时间:2019-01-24 20:11:51

标签: amazon-web-services amazon-s3 aws-sdk

在现有清单上执行listNextBatchOfObjects时,AWS s3客户端是否发出请求?例如:

   while (listing.isTruncated()) {
        listing = amazonS3Client.listNextBatchOfObjects(listing);
        final int paginatedObjectCount = listing.getObjectSummaries().size();
        objectCount += paginatedObjectCount;
    }

在这种情况下,amazonS3Client.listNextBatchOfObjects(listing)行会向S3请求吗?如果是这样,是否有办法从该请求中获取响应?

1 个答案:

答案 0 :(得分:0)

我想我明白了。您可以手动构造响应,以便上面的代码变为:

        ListNextBatchOfObjectsRequest nextBatchOfObjectsRequest = new ListNextBatchOfObjectsRequest(listing);
        listing = amazonS3Client.listNextBatchOfObjects(nextBatchOfObjectsRequest);
        S3ResponseMetadata s3ResponseMetadata = amazonS3Client.getCachedResponseMetadata(nextBatchOfObjectsRequest);
        final int paginatedObjectCount = listing.getObjectSummaries().size();
        objectCount += paginatedObjectCount;