A bucket is a container for objects stored in OSS. Every object is contained in a bucket. This topic describes how to create a bucket.

For the complete code used to create a bucket, visit GitHub.

The following code provides an example on how to create a bucket:

using Aliyun.OSS;

//Initialize an OSSClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);

// Create the bucket.
public void CreateBucket(string bucketName)
{
    try
    {
        // Create the bucket. A bucket name must be globally unique in OSS.
        client.CreateBucket(bucketName);
        Console.WriteLine("Create bucket succeeded");
    }
    catch (Exception ex)
    {
        Console.WriteLine("Create bucket failed. {0}", ex.Message);
    }
}
		

For more information about the bucket naming conventions, see Bucket.

For more information about how to create a bucket, see PutBucket.