A bucket is a container that stores objects in Object Storage Service (OSS). All objects are stored in buckets. This topic describes how to create a bucket.
Usage notes
Before you use the sample code in this topic, create an OSSClient instance using a custom domain name or Security Token Service (STS). For more information, see Initialization (iOS SDK).
NoteThe region of the bucket is determined by the endpoint that you specify during initialization.
From 10:00 (UTC+8) on October 13, 2025, OSS will implement a phased adjustment across all regions to enable Block Public Access by default for new buckets created using the API, OSS SDKs, or ossutil. For details about the exact times when the adjustment will take effect in each region, see [Official Announcement] Adjustment to the Public Access Blocking Configurations for Newly Created Buckets. Once Block Public Access is enabled, you cannot configure public access permissions, including public ACLs (public read and public read/write) and bucket policies that allows public access. You can disable this feature after the bucket is created if your business requires public access.
Permissions
By default, an Alibaba Cloud account has full permissions. RAM users or RAM roles under an Alibaba Cloud account do not have any permissions by default. The Alibaba Cloud account or account administrator must grant operation permissions through RAM Policy or Bucket policies.
API | Action | Definition |
PutBucket |
| Creates a bucket. |
| After creating a bucket, this permission is required to modify the bucket ACL. |
Sample code
The following code shows how to create a bucket named examplebucket:
// Construct a request to create a bucket.
OSSCreateBucketRequest * create = [OSSCreateBucketRequest new];
// Set the bucket name to examplebucket.
create.bucketName = @"examplebucket";
// Set the access control list (ACL) of the bucket to private.
create.xOssACL = @"private";
// Set the storage class of the bucket to Infrequent Access (IA).
create.storageClass = OSSBucketStorageClassIA;
OSSTask * createTask = [client createBucket:create];
[createTask continueWithBlock:^id(OSSTask *task) {
if (!task.error) {
NSLog(@"create bucket success!");
} else {
NSLog(@"create bucket failed, error: %@", task.error);
}
return nil;
}];
// Block the current thread to wait for the task to complete.
// [createTask waitUntilFinished]; References
For the complete sample code to create a bucket, see the GitHub example.
For more information about the API operation to create a bucket, see PutBucket.
For more information about how to initialize an OSSClient instance, see Initialize an OSSClient instance.