A bucket is a container used to store objects in Object Storage Service (OSS). All objects in OSS are contained in buckets. This topic describes how to query the access control list (ACL) of a bucket.
Bucket ACLs
The following table describes the ACLs of buckets.
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 |
Example
The following code provides an example on how to query the ACL of a bucket named examplebucket:
OSSGetBucketACLRequest *request = [OSSGetBucketACLRequest new];
// Specify the name of the bucket. Example: examplebucket.
request.bucketName = @"examplebucket";
// Query the ACL of the bucket.
OSSTask * getBucketACLTask = [client getBucketACL:request];
[getBucketACLTask continueWithBlock:^id(OSSTask *task) {
if (!task.error) {
OSSGetBucketACLResult *result = task.result;
NSLog(@"ACL:%@", result.aclGranted);
} else {
NSLog(@"get bucket ACL failed, error: %@", task.error);
}
return nil;
}];
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.