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.

The following code provides an example on how to call putBucket to create a bucket with a specified name:

let OSS = require('ali-oss');

let client = new OSS({
  region: '<Your region>',
  accessKeyId: '<Your AccessKeyId>',
  accessKeySecret: '<Your AccessKeySecret>'
});

// putBucket
async function putBucket() {
  try {
    const result = await client.putBucket('your bucket name');
    console.log(result);
  } catch (err) {
    console.log(err);
  }
}

putBucket();
		

For more information about the bucket naming conventions, see the "Naming conventions" section in Basic concepts. For more information about how to create a bucket, see Create buckets.

For more information about endpoints, see Regions and endpoints.