2016年11月24日 星期四
[Android][AWS] How to iterate all AWS S3 bucket access right 如何列舉 AWS S3 的所有 bucket
AWSCredentials creden = new BasicAWSCredentials("AKIAIIZCDEMXYJP5G3RA", "oBy8PZKgxAMKxw9sEhmvjfZ0seHNvE2SBLgyWN8i");
AmazonS3Client s3Client = new AmazonS3Client(creden);
List<Bucket> buckets = s3Client.listBuckets();
for (Bucket bucket : buckets) {
// Log.d("charles", bucket.getName());
try {
ListObjectsRequest lor = new ListObjectsRequest()
.withBucketName(bucket.getName());
ObjectListing objectListing = s3Client.listObjects(lor);
for (S3ObjectSummary summary: objectListing.getObjectSummaries()) {
// Log.d("charles", summary.getKey());
}
Log.d("charles", bucket.getName() + " : granted");
} catch (AmazonS3Exception e) {
Log.d("charles", bucket.getName() + " : AccessDenied");
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言