A bucket is a container used to store objects in Object Storage Service (OSS). Every object is contained in a bucket. This topic describes how to query the access control list (ACL) of a bucket.

The following table describes the bucket ACLs.

ACL Description Value
Private Only the owner or authorized users of the bucket have read and write permissions on objects in the bucket. Other users cannot access the objects in the bucket. private
Public read Only the owner or authorized users of the bucket have read and write permissions on objects in the bucket. Other users have only read permissions on the objects in the bucket. Exercise caution when you set the ACL of the bucket to this value. public-read
Public read/write All users have read and write permissions on objects in the bucket. Exercise caution when you set the ACL of the bucket to this value. public-read-write

Examples

The following code provides an example on how to query the ACL of a bucket:

GetBucketACLRequest getBucketACLRequest = new GetBucketACLRequest("bucketName");

// Query the ACL of the bucket. 
OSSAsyncTask getBucketAclTask = oss.asyncGetBucketACL(getBucketACLRequest, new OSSCompletedCallback<GetBucketACLRequest, GetBucketACLResult>() {
    @Override
    public void onSuccess(GetBucketACLRequest request, GetBucketACLResult result) {
        Log.d("asyncGetBucketACL", "Success!");
        Log.d("BucketAcl", result.getBucketACL());
        Log.d("Owner", result.getBucketOwner());
        Log.d("ID", result.getBucketOwnerID());
    }
    @Override
    public void onFailure(GetBucketACLRequest request, ClientException clientException, ServiceException serviceException) {
        // Handle request exceptions. 
        if (clientException != null) {
            // Handle client exceptions, such as network exceptions. 
            clientException.printStackTrace();
        }
        if (serviceException != null) {
            // Handle service exceptions. 
            Log.e("ErrorCode", serviceException.getErrorCode());
            Log.e("RequestId", serviceException.getRequestId());
            Log.e("HostId", serviceException.getHostId());
            Log.e("RawMessage", serviceException.getRawMessage());
        }
    }
});

References

  • For the complete sample code that is used to query the ACL of a bucket, visit GitHub.
  • For more information about the API operation that you can call to query the ACL of a bucket, see GetBucketAcl.