AWS S3 SDK ListObjectsV2 startafter 和 ContinuationToken 有什么区别?
AWS S3 SDK ListObjectsV2 what's difference between startafter and ContinuationToken?
我正在使用 Aws::S3::Model::ListObjectsV2Request
列出 AWS s3 中的对象。
(它是 c++ sdk,但我想实现与 Java 相同,所以如果您熟悉 Java AWS S3 sdk,请也看看我的问题)
根据 SDK 1000 条记录的限制,有超过 1000 个对象因此不能放在一页中。
我发现两个 API 似乎都可以合理地处理这个问题。
1.
// pseudo code
list_req
all_res = []
while true {
res = list_req.request()
all_res.add(res.get_all_entries())
if (res.isTruncated()) {
list_req.set_continuation_token(res.get_continuation_token());
}
}
2.
// pseudo code
list_req
all_res = []
while true {
res = list_req.request()
all_res.add(res.get_all_entries())
if (res.isTruncated()) {
list_req.set_start_after(res.get_last_entry());
}
}
这两种方法有什么区别? (我的情况是第一种方法会出现异常The continuation token provided is incorrect with address : 52.218.217.49
,所以我只能使用第二种方法。)
StartAfter (string) -- StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. StartAfter can be any key in the bucket.
ContinuationToken (string) -- ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key.
因此,如果您想从以 G
开头的对象开始列出存储桶,请使用 StartAfter = 'G'
。
返回结果超过1000条时使用ContinuationToken
。在这种情况下,响应会提供一个 ContinuationToken
,您必须将其传递给下一个调用。结果将从上次列表结束的地方继续。
如果要从特定名称开始并检索超过 1000 个对象,您可以同时指定这两个参数。
我正在使用 Aws::S3::Model::ListObjectsV2Request
列出 AWS s3 中的对象。
(它是 c++ sdk,但我想实现与 Java 相同,所以如果您熟悉 Java AWS S3 sdk,请也看看我的问题)
根据 SDK 1000 条记录的限制,有超过 1000 个对象因此不能放在一页中。
我发现两个 API 似乎都可以合理地处理这个问题。 1.
// pseudo code
list_req
all_res = []
while true {
res = list_req.request()
all_res.add(res.get_all_entries())
if (res.isTruncated()) {
list_req.set_continuation_token(res.get_continuation_token());
}
}
2.
// pseudo code
list_req
all_res = []
while true {
res = list_req.request()
all_res.add(res.get_all_entries())
if (res.isTruncated()) {
list_req.set_start_after(res.get_last_entry());
}
}
这两种方法有什么区别? (我的情况是第一种方法会出现异常The continuation token provided is incorrect with address : 52.218.217.49
,所以我只能使用第二种方法。)
StartAfter (string) -- StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. StartAfter can be any key in the bucket.
ContinuationToken (string) -- ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key.
因此,如果您想从以 G
开头的对象开始列出存储桶,请使用 StartAfter = 'G'
。
返回结果超过1000条时使用ContinuationToken
。在这种情况下,响应会提供一个 ContinuationToken
,您必须将其传递给下一个调用。结果将从上次列表结束的地方继续。
如果要从特定名称开始并检索超过 1000 个对象,您可以同时指定这两个参数。