gpt4 book ai didi

amazon-s3 - 为什么 ListObjects 将前缀作为数组中的单独对象返回?

转载 作者:行者123 更新时间:2023-12-03 06:44:04 25 4
gpt4 key购买 nike

我将 4 个对象上传到 S3。对象键如下:

4eec12eb0a588620cccad16f/MumDad70s.jpg
4eec12eb0a588620cccad16f/NathanI-1.jpg
4eec12eb0a588620cccad16f/ProfilePic.png
4eec12eb0a588620cccad16f/nathan-orange.jpg

我请求对象的代码是:

var req = new ListObjectsRequest()
.WithBucketName(BucketName)
.WithPrefix(jobid + "/")
.WithDelimiter("/");
var objs = _s3Client.ListObjects(req);

在响应中,即使前缀实际上不是它自己的对象,而只是附加到实际对象的键前面的字符串,我得到以下5 返回的对象:

4eec12eb0a588620cccad16f/
4eec12eb0a588620cccad16f/MumDad70s.jpg
4eec12eb0a588620cccad16f/NathanI-1.jpg
4eec12eb0a588620cccad16f/ProfilePic.png
4eec12eb0a588620cccad16f/nathan-orange.jpg

为什么返回的前缀就好像它是一个唯一的对象?如何返回具有指定前缀的文件,而无需对列表进行后过滤以删除前缀对象?

最佳答案

按照此处(是的,我意识到您可能不需要 Java 文档):http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3.html#listObjects%28com.amazonaws.services.s3.model.ListObjectsRequest%29

它指出:

If calling listObjects with a prefix value of "foo/" and a delimiter value of "/" on this bucket, an ObjectListing is returned that contains one key ("foo/boo") and one entry in the common prefixes list ("foo/bar/"). To see deeper into the virtual hierarchy, make another call to listObjects setting the prefix parameter to any interesting common prefix to list the individual keys under that prefix.

强调我的。看起来这实际上是预期的功能 - 返回所有键共有的前缀。

关于amazon-s3 - 为什么 ListObjects 将前缀作为数组中的单独对象返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8554990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com