简体   繁体   English

AWS S3 JAVA SDK-listObjects返回不完整的目录列表

[英]AWS S3 JAVA SDK - listObjects returns incomplete directory listings

When i use the listObjects() method, AWS returns a list of files and folders similar to this: 当我使用listObjects()方法时,AWS返回类似于此的文件和文件夹列表:

root/
root/projects/
root/projects/101/
root/projects/102/
root/projects/102/file1.pdf
root/images/image1.png
root/images/image2.png
root/favicon.ico

My results are not being truncated, and I'm wondering why it doesn't return a record for root/images/ I am not using the delimiter feature. 我的结果没有被截断,我想知道为什么它不返回root / images的记录/我没有使用定界符功能。

If You use as following, The List Object will have all the objects in the S3 Bucket. 如果您按以下方式使用,则列表对象将在S3存储桶中具有所有对象。 ListObjectsRequest lor = new ListObjectsRequest().withBucketName("myBucket"); ListObjectsRequest或= new ListObjectsRequest()。withBucketName(“ myBucket”); ObjectListing objectListing = s3.listObjects(lor); ObjectListing objectListing = s3.listObjects(lor);

If you want to have only objects in a specified directory as you said root/images, you need to specify as 如果您只想像指定的根目录/映像中那样在指定目录中包含对象,则需要指定为

ListObjectsRequest lor = new ListObjectsRequest().withBucketName("myBucket").withPrefix("image/"); ListObjectsRequest或=新的ListObjectsRequest()。withBucketName(“ myBucket”)。withPrefix(“ image /”);

Hope it helps 希望能帮助到你

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

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