A bucket is a container used to store objects in Object Storage Service (OSS). All objects in OSS are stored in buckets. 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 bucket owner and authorized users have read and write permissions on objects in the bucket. Other users cannot access objects in the bucket. | private |
Public-read | Only the bucket owner and authorized users have read and write permissions on objects in the bucket. Other users have only read permissions on objects in the bucket. Exercise caution when you set the bucket ACL 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 bucket ACL to this value. | public-read-write |
Examples
The following sample 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.
For more information about how to initialize an OSSClient instance, see Initialization.