简体   繁体   English

Amazon S3-列出所有不带层次结构摘要的对象

[英]Amazon S3 - List ALL objects without hierarchy summaries

For what it's worth, the Amazon S3 library is being used to perform operations on HCP. 就其价值而言,Amazon S3库用于在HCP上执行操作。 Perhaps that limits the version of Amazon S3 we can use or changes the interpretation of a folder. 也许那限制了我们可以使用的Amazon S3版本或更改了文件夹的解释。 My understanding is, both Amazon S3 and HCP can acknowledge full paths as objects and ignore the folders, but I'm having difficulty getting my requests to do just that. 我的理解是,Amazon S3和HCP都可以将完整路径确认为对象,而忽略文件夹,但是我很难做到这一点。

Say I have: 说我有:

  • something/over/here/object1 什么/在/在这里/ object1
  • something/over/there/object2 东西/上/有/对象2
  • somewhere/far/object3 地方/远/ object3

and I want every object under something/. 我希望每个物体都在某物之下。 Here is my request attempt: 这是我的请求尝试:

ListObjectsRequest listSomeObjects= new ListObjectsRequest()
.withBucketName("bucket")
.withDelimiter("/")
.withPrefix("something/")
.withMaxKeys("100") // maybe not necessary since it stops at 1000
.withMarker(null); // to be used after first request, I imagine
ObjectListing objectsReturned = this.hs3Client.listObjects(listSomeObjects);

objectsReturned gives me a few options: objectsReturned给了我一些选择:

  • getCommonPrefixes() - if I include a delimiter, returns something/over. getCommonPrefixes()-如果我包含定界符,则返回内容/结束。 Otherwise, appears to be empty. 否则,显示为空。
  • getObjectSummaries() - With the delimiter, only returns objects immediately under something/ and itself. getObjectSummaries()-使用定界符,仅返回在something /及其下的对象。 In this case, it only has itself. 在这种情况下,它只有它自己。 Without the delimiter, returns a list of object summaries for something/, something/over/, something/over/here, something/over/there/, something/over/here/object1, something/over/there/object2. 如果没有定界符,则返回某物,某物/上方/,某物/上方/此处,某物/上方/那里/,某物/上方/此处/对象1,某物/上方/那里/对象2的对象摘要列表。
  • getBucketName(), getMarker(), getMaxKeys(), getDelimiter(), getNextMarker(), getPrefix() - these don't appear to be anything I need getBucketName(),getMarker(),getMaxKeys(),getDelimiter(),getNextMarker(),getPrefix()-这些似乎不是我需要的东西

I only need a list of the full object names: something/over/here/object1, something/over/there/object2 我只需要完整对象名称的列表:something / over / here / object1,something / over / there / object2

Looping through all of getObjectSummaries() to filter the results would be a last resort. 遍历所有getObjectSummaries()来过滤结果将是最后的选择。 Using an incredible amount of small requests to account for the subfolders may not even be viable for our use case. 在我们的用例中,使用数量惊人的小请求来说明子文件夹可能甚至不可行。 Is there a way to get a list of full object names with a common prefix without going through all the keys in getObjectSummaries()? 有没有一种方法可以获取具有公共前缀的完整对象名称列表,而无需遍历getObjectSummaries()中的所有键?

Which amazon library version are you using? 您正在使用哪个亚马逊图书馆版本?

I can tell you that i've been using 我可以告诉你我一直在使用

AmazonS3.listObjects(String bucketName, String prefix)

and i only received the list of existing matching keys. 而且我只收到了现有匹配键的列表。 Only actual objects, not the "virtual folder" subpaths (using getObjectSummaries method as you do) 仅实际对象,而不是“虚拟文件夹”子路径(像使用getObjectSummaries方法一样)

As far as i know that is equivalent to your code but without the delimiter (keeping aside maxkeys). 据我所知,这等效于您的代码,但没有定界符(保留maxkeys)。

I used version 1.10.52 just in case it matters (would be surprised). 我使用了1.10.52版,以防万一(很惊讶)。

删除.withDelimiter("/")选项将使您获得前缀下的所有对象

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

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