Create a bucket (Harmony SDK)
A bucket is a container for storing objects in Object Storage Service (OSS). All objects in OSS are stored inside buckets.
Usage notes
For supported regions and endpoints, see Regions and endpoints.
Starting October 13, 2025, at 10:00 (UTC+8), OSS rolled out a phased adjustment across all regions to enable Block public access by default for buckets created through the API, OSS SDKs, or ossutil. Once enabled, you cannot set public ACLs (public read or public read/write) or bucket policies that allow public access. If your use case requires public access, disable Block public access after the bucket is created. For the rollout schedule by region, see the official announcement.
Prerequisites
Before you begin, make sure that you have:
An Alibaba Cloud account with the required permissions. RAM users and RAM roles have no permissions by default — grant them access through RAM Policy or bucket policies
The
oss:PutBucketpermission to create a bucket(Optional) The
oss:PutBucketAclpermission to modify the bucket ACL after creation
Create a bucket
Parameters
The putBucket method accepts the following parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
bucket | string | Yes | Bucket name |
createBucketConfig.storageClass | EStorageClass | No | Storage class. Valid values: EStorageClass.STANDARD, EStorageClass.IA, EStorageClass.ARCHIVE, EStorageClass.COLD_ARCHIVE |
createBucketConfig.dataRedundancyType | EDataRedundancyType | No | Data redundancy type. Valid values: EDataRedundancyType.LRS (locally redundant), EDataRedundancyType.ZRS (zone-redundant storage) |
acl | EBucketAcl | No | Bucket access control list (ACL). Valid values: EBucketAcl.PRIVATE, EBucketAcl.PUBLIC_READ, EBucketAcl.PUBLIC_READ_WRITE |
resourceGroupId | string | No | ID of the resource group to associate with the bucket |
ACL values
| Value | Access |
|---|---|
EBucketAcl.PRIVATE | Bucket owner only has read and write access |
EBucketAcl.PUBLIC_READ | All users have read access; only bucket owner has write access |
EBucketAcl.PUBLIC_READ_WRITE | All users have read and write access |
Common scenarios
Create a bucket in a specific storage class
Pass storageClass in createBucketConfig to specify the storage class for the bucket.
const res = await client.putBucket({
bucket: '<your-bucket-name>',
createBucketConfig: {
storageClass: EStorageClass.ARCHIVE, // Archive storage class.
dataRedundancyType: EDataRedundancyType.ZRS,
},
});Create a bucket with a specific ACL
Pass acl to set the bucket's access control list (ACL) at creation time.
const res = await client.putBucket({
bucket: '<your-bucket-name>',
acl: EBucketAcl.PRIVATE,
createBucketConfig: {
dataRedundancyType: EDataRedundancyType.ZRS,
},
});Create a bucket in a specific resource group
Pass resourceGroupId to associate the bucket with a resource group.
const res = await client.putBucket({
bucket: '<your-bucket-name>',
resourceGroupId: '<your-resource-group-id>',
createBucketConfig: {
dataRedundancyType: EDataRedundancyType.ZRS,
},
});