You can query the access control list (ACL) of a bucket to check its current access permissions.
OSS supports the following bucket ACLs.
|
Access permissions |
Description |
Access permissions |
|
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 |
Usage notes
-
Before you run the sample code in this topic, you must create an OSSClient instance by using methods such as using a custom domain name or Security Token Service (STS). For more information, see Initialization (Android SDK).
Examples
The following code gets the bucket ACL:
GetBucketACLRequest getBucketACLRequest = new GetBucketACLRequest("bucketName");
// Get 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 for querying the ACL of a bucket, visit GitHub.
-
For the API operation used to query the ACL of a bucket, see GetBucketAcl.
-
For information about how to initialize an OSSClient instance, see Initialization.