0
考慮例如關於同步版本和老AWS SDK:如何通過aws sdk 2.0中的CompletableFuture迭代s3文件密鑰?
public void syncIterateObjects() {
AmazonS3 s3Client = null;
String marker = null;
do {
ObjectListing objects = s3Client.listObjects(
new ListObjectsRequest()
.withBucketName("bucket")
.withPrefix("prefix")
.withMarker(marker)
.withDelimiter("/")
.withMaxKeys(100)
);
marker = objects.getNextMarker();
} while (marker != null);
}
一切都清楚了 - 做/而做的工作。考慮異步例子,AWSD SDK 2.0
public void asyncIterateObjects() {
S3AsyncClient client = S3AsyncClient.builder().build()
final CompletableFuture<ListObjectsV2Response> response = client.listObjectsV2(ListObjectsV2Request.builder()
.delimiter("/")
.prefix("bucket")
.bucket("prefix")
.build())
.thenApply(Function.identity());
// what to do next ???
}
好吧我CompletableFuture,但如何運行週期來傳遞一個和下一個Future
之間(在AWS nextContinuationToken
SDK 2.0)的標記?