简体   繁体   English

AWS S3 SDK ListObjectsV2 startafter 和 ContinuationToken 有什么区别?

[英]AWS S3 SDK ListObjectsV2 what's difference between startafter and ContinuationToken?

I'm using Aws::S3::Model::ListObjectsV2Request to list objects in AWS s3.我正在使用Aws::S3::Model::ListObjectsV2Request列出 AWS s3 中的对象。

(It's c++ sdk, but I suppose the implementation is the same with Java, so if you're familiar with Java AWS S3 sdk pls also take a look at my question) (它是 c++ sdk,但我想实现与 Java 相同,所以如果您熟悉 Java AWS S3 sdk,请查看我的问题)

There're more than 1000 objects so can not fit in one page according to SDK 1000 records limit.有超过 1000 个对象,因此根据 SDK 1000 条记录限制不能放在一页中。

I found two API seems both reasonable to deal with this issue.我发现两个 API 似乎都可以合理地处理这个问题。 1. 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. 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());
    }
}

What's the difference between these two approaches?这两种方法有什么区别? (My situation is that I will get an exception with first approach The continuation token provided is incorrect with address : 52.218.217.49 , so I can only use the second one.) (我的情况是,第一种方法会出现异常 提供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. StartAfter (string) -- StartAfter 是您希望 Amazon S3 开始列出的位置。 Amazon S3 starts listing after this specified key. Amazon S3 在此指定键之后开始列出。 StartAfter can be any key in the bucket. StartAfter 可以是存储桶中的任何键。

ContinuationToken (string) -- ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken (字符串)——ContinuationToken 指示 Amazon S3 正在使用令牌在此存储桶上继续列表。 ContinuationToken is obfuscated and is not a real key. ContinuationToken 被混淆并且不是真正的密钥。

So, if you want to start listing a bucket from objects that begin with G , then use StartAfter = 'G' .因此,如果您想从以G开头的对象开始列出存储桶,请使用StartAfter = 'G'

The ContinuationToken is used when more than 1000 results were returned.当返回超过 1000 个结果时使用ContinuationToken In such a case, the response provides a ContinuationToken that you must pass into the next call.在这种情况下,响应会提供一个ContinuationToken ,您必须将其传递到下一次调用中。 The results will continue from where the last listing finished.结果将从上次列表结束的地方继续。

You can specify both of the parameters, if wanting to start at a particular name and retrieve more than 1000 objects.如果要从特定名称开始并检索 1000 多个对象,您可以指定这两个参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM