简体   繁体   English

所有文件夹名称都没有出现在 Amazon S3 的列表对象调用中

[英]All folder names are not coming in List objects call of Amazon S3

enter image description here I'm using the following code to list all the objects present in the bucket of S3.在此处输入图像描述我正在使用以下代码列出 S3 存储桶中存在的所有对象。 But the problem is not all the folder names are coming in the call.但问题不在于调用中的所有文件夹名称。 I've attached the image for reference.我附上了图片以供参考。

AmazonS3 s3Object = AmazonS3Utils.getS3Object(amazonS3ConnectionValues.regionName, amazonS3ConnectionValues.accessKey, amazonS3ConnectionValues.secretKey);
                s3Object.listBuckets();
                ListObjectsV2Result objectsList = s3Object.listObjectsV2(bucket);
                List<S3ObjectSummary> objectSummaries = objectsList.getObjectSummaries();
                for (S3ObjectSummary objectSummary : objectSummaries) {
                    Object[] newRow;
                    newRow = RowDataUtil.allocateRowData(data.outputRowMeta.size());
                    int index = 0;
                    newRow[index++] = objectSummary.getKey();
                    newRow[index++] = objectSummary.getETag();
                    newRow[index++] = objectSummary.getSize();
                    newRow[index++] = objectSummary.getLastModified();
                    newRow[index++] = objectSummary.getStorageClass();
                    putRow(data.outputRowMeta, newRow);

As shown in the image foldername "automationedge123/" is not shown in the response, other folder names such as "Test Folder/", "automationedge/" are shown in the output.如图所示文件夹名称“automationedge123/”未显示在响应中,其他文件夹名称如“Test Folder/”、“automationedge/”显示在 output 中。 I'm not understanding this behavior.我不理解这种行为。

The listObjects result might be paginated. listObjects 结果可能是分页的。 Make sure that you are not looking at a truncated result by looking at the return value of isTruncated() ( link ).通过查看isTruncated() ( link ) 的返回值,确保您没有查看截断的结果。

Here's a quote from the javadoc of listObjects(...)] ( link )这是来自listObjects(...)]的 javadoc 的引用( 链接

Because buckets can contain a virtually unlimited number of keys, the complete results of a list query can be extremely large.因为桶可以包含几乎无限数量的键,所以列表查询的完整结果可能非常大。 To manage large result sets, Amazon S3 uses pagination to split them into multiple responses.为了管理大型结果集,Amazon S3 使用分页将它们拆分为多个响应。 Always check the ObjectListing.isTruncated() method to see if the returned listing is complete or if additional calls are needed to get more results.始终检查 ObjectListing.isTruncated() 方法以查看返回的列表是否完整,或者是否需要额外调用才能获得更多结果。 Alternatively, use the AmazonS3Client.listNextBatchOfObjects(ObjectListing) method as an easy way to get the next page of object listings.或者,使用 AmazonS3Client.listNextBatchOfObjects(ObjectListing) 方法作为获取下一页 object 列表的简单方法。

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

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