我正在使用AmazonS3Client示例代码下方通过aws api网关从 S3 存储桶中获取带有前缀的文件列表。 但是我得到了那个桶的所有文件。
当我检查api网关日志中的网址时,网址中没有前缀参数。
提前致谢
ListObjectsV2Request req = new ListObjectsV2Request().withBucketName("mybucket").withPrefix("myfolder").withDelimiter("/");
req.putCustomRequestHeader("Authorization", "#####");
ListObjectsV2Result result;
do {
result = s3Client.listObjectsV2(req);
for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
System.out.printf(" - %s (size: %d)\n", objectSummary.getKey(), objectSummary.getSize());
}
// If there are more than maxKeys keys in the bucket, get a continuation token
// and list the next objects.
String token = result.getNextContinuationToken();
System.out.println("Next Continuation Token: " + token);
req.setContinuationToken(token);
} while (result.isTruncated());