rtafter和ContinuationToken之间有什么区别

rtafter和ContinuationToken之间有什么区别

本文介绍了AWS S3 SDK ListObjectsV2 startafter和ContinuationToken之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Aws :: S3 :: Model :: ListObjectsV2Request 列出AWS s3中的对象.

I'm using Aws::S3::Model::ListObjectsV2Request to list objects in AWS s3.

(这是c ++ sdk,但我想实现与Java相同,因此,如果您熟悉Java,则AWS AWS S3 sdk请也看看我的问题)

(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)

有超过1000个对象,因此根据SDK 1000记录限制,不能容纳在一页中.

There're more than 1000 objects so can not fit in one page according to SDK 1000 records limit.

我发现两个API似乎都可以解决这个问题.1.

I found two API seems both reasonable to deal with this issue.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());
    }
}

这两种方法有什么区别?(我的情况是,第一种方法我将得到一个例外,因为提供的延续令牌的地址不正确:52.218.217.49 ,所以我只能使用第二种方法.)

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.)

推荐答案

ContinuationToken (字符串)-ContinuationToken指示Amazon S3该列表正在此存储桶中以令牌形式继续.ContinuationToken被混淆,不是真正的密钥.

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'.

So, if you want to start listing a bucket from objects that begin with G, then use StartAfter = 'G'.

返回超过1000个结果时使用 ContinuationToken .在这种情况下,响应会提供一个 ContinuationToken ,您必须将其传递给下一个调用.结果将从上一个列表结束处继续.

The ContinuationToken is used when more than 1000 results were returned. In such a case, the response provides a ContinuationToken that you must pass into the next call. The results will continue from where the last listing finished.

如果要以特定名称开头并检索1000个以上的对象,则可以指定两个参数.

You can specify both of the parameters, if wanting to start at a particular name and retrieve more than 1000 objects.

这篇关于AWS S3 SDK ListObjectsV2 startafter和ContinuationToken之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 08:09