本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3.listObjects方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3.listObjects方法的具体用法?Java AmazonS3.listObjects怎么用?Java AmazonS3.listObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3
的用法示例。
在下文中一共展示了AmazonS3.listObjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBucketObjectSummaries
import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
public static List<S3ObjectSummary> getBucketObjectSummaries(String bucket, String prefix) {
String realBucket = getBucketFromFullPath(bucket);
String preprefix = getPrefixFromFullPath(bucket);
AmazonS3 s3Client = AmazonS3Provider.getS3Client();
ListObjectsRequest req = new ListObjectsRequest().withBucketName(realBucket).withPrefix(!preprefix.equals("") ? preprefix + "/" + prefix : prefix);
ObjectListing objectListing = s3Client.listObjects(req);
List<S3ObjectSummary> summaries = objectListing.getObjectSummaries();
while (objectListing.isTruncated()) {
objectListing = s3Client.listNextBatchOfObjects(objectListing);
summaries.addAll(objectListing.getObjectSummaries());
}
return summaries.stream().filter(obj -> !obj.getKey().equals("") && !obj.getKey().endsWith("/")).collect(toList());
}
示例2: listObjects
import com.amazonaws.services.s3.AmazonS3; //导入方法依赖的package包/类
public static List<S3ObjectSummary> listObjects(AmazonS3 client, String bucket) {
ObjectListing objects = client.listObjects(bucket);
List<S3ObjectSummary> result = new ArrayList<>(objects.getObjectSummaries().size());
for (S3ObjectSummary objectSummary : objects.getObjectSummaries()) {
if (objectSummary.getKey().endsWith("/") || objectSummary.getKey().endsWith("_$folder$")) {
continue;
}
result.add(objectSummary);
}
return result;
}