調用DeleteBucket刪除某個存儲空間(Bucket)。
重要
只有Bucket的擁有者才有權限刪除該Bucket。
為了防止誤刪除的發生,OSS不允許刪除一個非空的Bucket。
請求語法
DELETE / HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
當您在OSS ON云盒中調用該接口時,您需要將Host替換為云盒Endpoint。更多信息,請參見云盒Endpoint。
請求頭
此接口僅涉及公共請求頭。更多信息,請參見公共請求頭(Common Request Headers)。
響應頭
此接口僅涉及公共響應頭。更多信息,請參見公共響應頭(Common Response Headers)。
示例
正常刪除的請求示例
DELETE / HTTP/1.1 Host: test.oss-cn-hangzhou.aliyuncs.com Accept-Encoding: identity User-Agent: aliyun-sdk-python/2.6.0(Windows/7/AMD64;3.7.0) Accept: */* Connection: keep-alive date: Tue, 15 Jan 2019 08:19:04 GMT authorization: OSS qn6qrrqxo2oawuk53otfjbyc:ceOEyZavKY4QcjoUWYSpYbJ3**** Content-Length: 0
返回示例
HTTP/1.1 204 No Content Server: AliyunOSS Date: Tue, 15 Jan 2019 08:19:04 GMT Content-Length: 0 Connection: keep-alive x-oss-request-id: 5C3D9778CC1C2AEDF85B**** x-oss-server-time: 190
刪除的Bucket不存在的請求示例
DELETE / HTTP/1.1 Host: test.oss-cn-hangzhou.aliyuncs.com Accept-Encoding: identity User-Agent: aliyun-sdk-python/2.6.0(Windows/7/AMD64;3.7.0) Accept: */* Connection: keep-alive date: Tue, 15 Jan 2019 07:53:24 GMT authorization: OSS qn6qrrqxo2oawuk53otfjbyc:ceOEyZavKY4QcjoUWYSpYbJ3**** Content-Length: 0
返回示例
HTTP/1.1 404 Not Found Server: AliyunOSS Date: Tue, 15 Jan 2019 07:53:25 GMT Content-Type: application/xml Content-Length: 288 Connection: keep-alive x-oss-request-id: 5C3D9175B6FC201293AD**** <?xml version="1.0" encoding="UTF-8"?> <Error> <Code>NoSuchBucket</Code> <Message>The specified bucket does not exist.</Message> <RequestId>5C3D9175B6FC201293AD****</RequestId> <HostId>test.oss-cn-hangzhou.aliyuncs.com</HostId> <BucketName>test</BucketName> <EC>0015-00000101</EC> </Error>
刪除的Bucket非空的請求示例
DELETE / HTTP/1.1 Host: test.oss-cn-hangzhou.aliyuncs.com Accept-Encoding: identity User-Agent: aliyun-sdk-python/2.6.0(Windows/7/AMD64;3.7.0) Accept: */* Connection: keep-alive date: Tue, 15 Jan 2019 07:35:06 GMT authorization: OSS qn6qrrqxo2oawuk53otfjbyc:ceOEyZavKY4QcjoUWYSpYbJ3**** Content-Length: 0
返回示例
HTTP/1.1 409 Conflict Server: AliyunOSS Date: Tue, 15 Jan 2019 07:35:06 GMT Content-Type: application/xml Content-Length: 296 Connection: keep-alive x-oss-request-id: 5C3D8D2A0ACA54D87B43**** x-oss-server-time: 16 <?xml version="1.0" encoding="UTF-8"?> <Error> <Code>BucketNotEmpty</Code> <Message>The bucket has objects. Please delete them first.</Message> <RequestId>5C3D8D2A0ACA54D87B43****</RequestId> <HostId>test.oss-cn-hangzhou.aliyuncs.com</HostId> <BucketName>test</BucketName> <EC>0015-00000301</EC> </Error>
SDK
此接口所對應的各語言SDK如下:
錯誤碼
錯誤碼 | HTTP狀態碼 | 描述 |
AccessDenied | 403 Forbidden | 沒有刪除該Bucket的權限。只有Bucket的擁有者才能刪除該Bucket。 |
文檔內容是否對您有幫助?