获取桶访问权限

您可以使用getBucketAcl接口获取桶的访问权限。以下代码展示如何获取桶的访问权限:

String bucketName = "<your-bucket-name>";
try {
    AccessControlList acl = s3.getBucketAcl(bucketName);
    List<Grant> grants = acl.getGrantsAsList();
    for (Grant grant : grants) {
        System.out.format(" %s: %s\n", grant.getGrantee().getIdentifier(), grant.getPermission().toString());
    }
} catch (AmazonServiceException e) {
    System.err.println(e.getErrorMessage());
}