This operation is used to create a bucket with a specified name.
A bucket name must be unique in OBS. If a user creates a bucket with the same name as that of an existing bucket under the same account and in the same region, a 200 code (indicating success) is returned. In scenarios other than the preceding one, the request for creating a bucket with the same name as that of an existing one will receive the 409 code (indicating that a namesake bucket already exists). To set an access control policy for the bucket to be created, you can add the x-obs-acl parameter to request headers.
You can create buckets with different storage classes. The x-obs-storage-class header in a bucket creation request specifies the bucket's storage class. If you do not specify a storage class when you upload an object to the bucket, the object inherits the storage class of the bucket. The storage class options are as follows: STANDARD (Standard), WARM (Warm), COLD (Cold). If the x-obs-storage-class header is not in the request, a Standard bucket will be created.
If the storage class of an object is not specified when it is uploaded to a bucket (see Uploading an Object - PUT), the object will be stored in the default storage class of the bucket.
12345678910PUT / HTTP/1.1Host: bucketname.obs.region.example.comContent-Length: lengthDate: dateAuthorization: authorizationx-obs-az-redundancy: 3az<CreateBucketConfiguration xmlns="http://obs.region.example.com/doc/2015-06-30/"><Location>location</Location></CreateBucketConfiguration>
This request contains no parameters.
The operation message header is the same as that of a common request. For details, see Table 3. However, this request can contain additional headers. The following table describes the additional headers for this request. Note that the bucket name is specified in the Host field of Table 3.
Header | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
x-obs-acl | String | No | Definition: When creating a bucket, you can use this parameter to set a pre-defined ACL. Range:
Default value: private |
x-obs-storage-class | String | No | Definition: When creating a bucket, you can add this header to set the default storage class for the bucket. Range:
Default value: STANDARD |
x-obs-grant-read | String | No | Definition: Grants the read permission to all users in a specified domain. It allows you to list objects in a bucket, list multipart tasks in a bucket, list multi-version objects in a bucket, and obtain bucket metadata. Example: x-obs-grant-read:id=tenant-ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-grant-write | String | No | Definition: Grants the WRITE permission to all users in a specified domain to create, delete, and overwrite all objects in a bucket; and initiate multipart uploads, upload parts, copy parts, assemble parts, and cancel multipart uploads. Example: x-obs-grant-write:id=tenant-ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-grant-read-acp | String | No | Definition: Grant the READ_ACP permission to all users in a specified domain to allow them to read the bucket ACL. Example: x-obs-grant-read-acp:id=Account ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-grant-write-acp | String | No | Definition: Grants the WRITE_ACP permission to all users in a specified domain to allow them to modify the bucket ACL. Example: x-obs-grant-write-acp:id=Account ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-grant-full-control | String | No | Definition: Grants the FULL_CONTROL permission to all users in a specified domain. Example: x-obs-grant-full-control:id=tenant-ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-grant-read-delivered | String | No | Definition: Grants the READ permission to all users in a specified domain. By default, the read permission is granted on all objects in the bucket. Example: x-obs-grant-read-delivered:id=tenant-ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-grant-full-control-delivered | String | No | Definition: Grants the FULL_CONTROL permission to all users in a specified domain. By default, the FULL_CONTROL permission is granted on all objects in the bucket. Example: x-obs-grant-full-control-delivered:id=tenant-ID Constraints: None Range: id=tenant-ID. For details, see Obtaining a Domain ID and a User ID. Default value: None |
x-obs-az-redundancy | String | No | Definition: When creating a bucket, you can use this header to set the data redundancy policy for the bucket. Constraints: If a region does not support multi-AZ storage, even if this header is specified, the bucket is still single-AZ. Range:
Default value: If this header is not specified, single AZ applies. |
x-obs-fs-file-interface | String | No | Definition: This header can be carried when you want to create a parallel file system. Example: x-obs-fs-file-interface:Enabled Range: Enabled Default value: If the header is specified, the value must be Enabled. There is no default value. |
x-obs-epid | String | No | Definition: Enterprise project ID. Users who have enabled the enterprise project function can obtain this ID in UUID format from the enterprise project service. The default project ID is 0. This header can be not included. This header is not required for users who have not enabled the enterprise project function. Example: x-obs-epid:9892d768-2d13-450f-aac7-ed0e44c2585f Constraints: None Range: The value can be 0 or your actual enterprise project ID. Default value: 0 |
x-obs-bucket-object-lock-enabled | String | No | Definition: When creating a bucket, you can use this header to enable WORM for the bucket. Example: x-obs-bucket-object-lock-enabled:true Constraints: Only object buckets are supported. Range:
Default value: If the header is specified, the value must be true or True. If the header is not specified, the object lock policy is disabled. |
This request can use additional elements. For details about additional elements, see Table 2.
Element | Type | Mandatory (Yes/No) | Description |
|---|---|---|---|
Location | String | No | Definition: Specifies the region where a bucket will be created.
Range: For details about OBS regions and endpoints, see Regions and Endpoints. |
1234HTTP/1.1 status_codeLocation: locationDate: dateContent-Length: length
The response to the request uses common headers. For details, see Table 1.
This response contains no elements.
No special error responses are returned. For details about error responses, see Table 2.
1234567891011PUT / HTTP/1.1User-Agent: curl/7.29.0Host: examplebucket.obs.region.example.comAccept: */*Date: WED, 01 Jul 2015 02:25:05 GMTAuthorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw=Content-Length: 157<CreateBucketConfiguration xmlns="http://obs.region.example.com/doc/2015-06-30/"><Location>region</Location></CreateBucketConfiguration>
1234567HTTP/1.1 200 OKServer: OBSx-obs-request-id: BF260000016435CE298386946AE4C482Location: /examplebucketx-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUzDate: WED, 01 Jul 2015 02:25:06 GMTContent-Length: 0
12345678910111213PUT / HTTP/1.1User-Agent: curl/7.29.0Host: examplebucket.obs.region.example.comAccept: */*Date: WED, 01 Jul 2015 02:25:05 GMTx-obs-acl:public-readx-obs-storage-class:STANDARDAuthorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw=Content-Length: 157<CreateBucketConfiguration xmlns="http://obs.region.example.com/doc/2015-06-30/"><Location>region</Location></CreateBucketConfiguration>
1234567HTTP/1.1 200 OKServer: OBSx-obs-request-id: BF260000016435CE298386946AE4C482Location: /examplebucketx-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUzDate: WED, 01 Jul 2015 02:25:06 GMTContent-Length: 0
123456789PUT / HTTP/1.1Host: examplebucket.obs.region.example.comContent-Length: lengthDate: dateAuthorization: authorizationx-obs-az-redundancy: 3az<CreateBucketConfiguration xmlns="http://obs.region.example.com/doc/2015-06-30/"><Location>region</Location></CreateBucketConfiguration>
1234567HTTP/1.1 200 OKServer: OBSx-obs-request-id: BF260000016435CE298386946AE4C482Location: /examplebucketx-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUzDate: WED, 01 Jul 2015 02:25:06 GMTContent-Length: 0
123456789101112PUT / HTTP/1.1User-Agent: curl/7.29.0Host: examplebucket.obs.region.example.comAccept: */*Date: WED, 01 Jul 2015 02:25:05 GMTAuthorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw=Content-Length: 157x-obs-fs-file-interface: Enabled<CreateBucketConfiguration xmlns="http://obs.region.example.com/doc/2015-06-30/"><Location>region</Location></CreateBucketConfiguration>
1234567HTTP/1.1 200 OKServer: OBSx-obs-request-id: BF260000016435CE298386946AE4C482Location: /examplebucketx-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUzDate: WED, 01 Jul 2015 02:25:06 GMTContent-Length: 0
PUT / HTTP/1.1User-Agent: curl/7.29.0Host: examplebucket.obs.region.example.comAccept: */*Date: WED, 01 Jul 2015 02:25:05 GMTAuthorization: OBS H4IPJX0TQTHTHEBQQCEC:75/Y4Ng1izvzc1nTGxpMXTE6ynw=x-obs-bucket-object-lock-enabled:trueContent-Length: 0
HTTP/1.1 200 OKServer: OBSx-obs-request-id: 00000184C11AC7A6809F881341842C02x-reserved-indicator: UnauthorizedLocation: /examplebucketx-obs-id-2: 32AAAQAAEAABSAAgAAEAABAAAQAAEAABCT9W2tcvLmMJ+plfdopaD62S0npbaRUzDate: WED, 01 Jul 2015 02:25:06 GMTContent-Length: 0