Updated on 2024-02-18 GMT+08:00

Deleting Buckets

Functions

This operation deletes specified buckets. This operation can be performed only by the bucket owner and users who have been authorized (via a policy) with the permission to delete the bucket. The bucket to be deleted must be an empty bucket. If a bucket has an object or a multipart task, the bucket is not empty. You can list objects and multipart upload tasks in a bucket to check whether the bucket is empty.

Note:

If the server returns a 5XX error or times out when a bucket is being deleted, the system needs to synchronize the bucket information. During this period, the bucket information may be inaccurate. Therefore, wait a while and then check whether the bucket is successfully deleted. If the bucket can still be queried, send the deletion request again.

Request Syntax

1
2
3
4
DELETE / HTTP/1.1 
Host: bucketname.obs.region.myhuaweicloud.com 
Date: date
Authorization: authorization

Request Parameters

This request contains no parameters.

Request Headers

This request uses common request headers. For details, see Table 3.

Request Elements

This request involves no elements.

Response Syntax

1
2
HTTP/1.1 status_code
Date: date

Response Headers

The response to the request uses common headers. For details, see Table 1.

Response Elements

This response contains no elements.

Error Responses

No special error responses are returned. For details about error responses, see Table 2.

Sample Request

1
2
3
4
5
6
DELETE / HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Accept: */*
Date: WED, 01 Jul 2015 02:31:25 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:jZiAT8Vx4azWEvPRMWi0X5BpJMA=

Sample Response

1
2
3
4
5
HTTP/1.1 204 No Content
Server: OBS
x-obs-request-id: BF260000016435DE6D67C35F9B969C47
x-obs-id-2: 32AAAQAAEAABKAAQAAEAABAAAQAAEAABCTukraCnXLsb7lEw4ZKjzDWWhzXdgme3
Date: WED, 01 Jul 2015 02:31:25 GMT

Sample Request: Deleting a Bucket That Does Not Exist

DELETE / HTTP/1.1
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4=User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml;charset=UTF-8

Sample Response: Deleting a Bucket That Does Not Exist

x-obs-id-2: "32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTBZPaontVN8iyR2NNEeTPRDdcmPVNFm
x-obs-request-id: "0000018A4E4567BD47CF110EE1B2A4DF
Server: OBS
Content-Length: 314
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>NoSuchBucket</Code>
    <Message>The specified bucket does not exist</Message>
    <RequestId>0000018A4E4567BD47CF110EE1B2A4DF</RequestId>
    <HostId>DRmhM6VfpWGBYYGrx6tpvbs8yoGi+uvlu5/20rpZ/Y2kTuq9mRuCXeA84734xs0+</HostId>
    <BucketName>examplebucket</BucketName>
</Error>

Sample Request: Deleting a Non-Empty Bucket

DELETE / HTTP/1.1
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4=User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml;charset=UTF-8

Sample Response: Deleting a Non-Empty Bucket

x-obs-id-2: "32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTBZPaontVN8iyR2NNEeTPRDdcmPVNFm
x-obs-request-id: "0000018A4E4567BD47CF110EE1B2A4DF
Server: OBS
Content-Length: 314
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>BucketNotEmpty</Code>
    <Message>The bucket you tried to delete is not empty</Message>
    <RequestId>0000018A4E4D04BBD304AD8E409873EC</RequestId>
    <HostId>hME9234LDBKRFuuobDsmyUiP5Oq71oYo1vEL348QzfXHUoGs1RU1TgrOMUKTEMtA</HostId>
    <BucketName>examplebucket</BucketName>
</Error>