A bucket is a container for objects stored in OSS. Every object is contained in a bucket. This topic describes how to query the ACL of a bucket.

Bucket ACL

The following table describes the ACLs of buckets.

ACL Description Value
Private Only the owner or authorized users of this bucket can read and write objects in the bucket. Other users, including anonymous users cannot access the objects in the bucket without authorization. private
Public read Only the owner or authorized users of this bucket can write objects in the bucket. Other users, including anonymous users can only read objects in the bucket. We recommend that you exercise with caution when you set the bucket ACL to public read. public-read
Public read/write Any users, including anonymous users can read and write objects in the bucket. Exercise caution when set the bucket ACL to public read/write. public-read-write

Examples

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

OSSGetBucketACLRequest *request = [OSSGetBucketACLRequest new];
request.bucketName = @"examplebucket";

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;
}];