Create Bucket
Updated at:2025-11-03
The following code can be used to create a bucket:
Ruby
1bucketName = "your_bucket";
2# Whether the bucket exists, if not, create the bucket
3client.create_bucket(bucket_name) unless client.does_bucket_exist(bucket_name)
Note: Since the bucket name is unique across all regions, it is necessary to ensure that the bucketName is not the same as the BucketName on all other regions.
Bucket naming follows the following conventions:
- Only lowercase letters, numbers, and hyphens (-) are allowed.
- Must start with a lowercase letter or a number.
- Length should range between 4-63 bytes.
The bucket created using the above example has private read-write permissions and a Standard storage class. Users can customize the bucket permissions and storage class when creating a bucket in the console.
