A bucket is a container that is used to store objects in Object Storage Service (OSS). You must create a bucket before you upload any objects to OSS. This topic describes how to create a bucket by using the mb command.
Create a bucket based on the options that are specified in the command
Command syntax
./ossutil64 mb oss://bucketname
[--acl <value>]
[--storage-class <value>]
[--redundancy-type <value>]
The following table describes the parameters that are used in the preceding statements.
Parameter | Description |
---|---|
bucketname | The name of the bucket that you want to create. A bucket name must be globally unique within OSS. The name of a bucket cannot be changed after the bucket is created. |
--acl | The access control list (ACL) of the bucket. Default value: private. Valid values:
|
--storage-class | The storage class of the bucket. Default value: Standard. Valid values:
For more information about storage classes, see Overview. |
--redundancy-type | The redundancy type of the bucket. Default value: LRS. Valid values:
Note Zone-redundant storage (ZRS) is supported in the following regions: China (Shenzhen), China (Beijing), China (Hangzhou), China (Shanghai), China (Hong Kong), Singapore, and Indonesia (Jakarta). You are charged additional fees for ZRS. This feature cannot be disabled after it is enabled. Exercise caution when you enable this feature. |
Examples
- You can run the following command to create a bucket named examplebucket:
./ossutil64 mb oss://examplebucket
If you do not specify the region in which you want to create the bucket, the bucket is created in the region specified by the endpoint in the ossutil configuration file. For example, if the endpoint specified in the configuration file is
https://oss-cn-hangzhou.aliyuncs.com
, the bucket is created in the China (Hangzhou) region. - You can run the following command to create a bucket named examplebucket and set the ACL of the bucket to private, storage class to IA, and redundancy type to ZRS:
./ossutil64 mb oss://examplebucket --acl private --storage-class IA --redundancy-type ZRS
- If the following output is displayed, the examplebucket bucket is created:
0.335189(s) elapsed
Create a bucket based on the XML structure that is specified in the command
Command syntax
./ossutil64 mb oss://bucketname local_xml_file
The following table describes the parameters that are used in the preceding statements.
Parameter | Description |
---|---|
bucketname | The name of the bucket that you want to create. |
local_xml_file | The local file path that contains bucket configurations, such as localfile.xml . |
Examples
- You can run the following command to specify the bucket configurations based on the XML structure in the local file path
localfile.xml
:<?xml version="1.0" encoding="UTF-8"?> <CreateBucketConfiguration> <StorageClass>IA</StorageClass> <DataRedundancyType>LRS</DataRedundancyType> </CreateBucketConfiguration>
- You can run the following command to obtain the bucket configurations from the local file path by using ossutil and add the configurations to the bucket that you want to create:
./ossutil64 mb oss://examplebucket localfile.xml
Common options
If you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, you can add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account.
./ossutil64 mb oss://examplebucket -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA**** -k 67DLVBkH7EamOjy2W5RVAHUY9H****
For more information about other common options that you can specify in the sync command, see Common options.