DeleteObject用于删除某个文件(Object)。使用DeleteObject需要对该Object有写权限。

说明 如果Object类型为软链接,使用DeleteObject仅会删除该软链接。

请求语法

DELETE /ObjectName HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

示例

请求示例
DELETE /AK.txt HTTP/1.1
Host: test.oss-cn-zhangjiakou.aliyuncs.com
Accept-Encoding: identity
User-Agent: aliyun-sdk-python/2.6.0(Windows/7/AMD64;3.7.0)
Accept: */*
Connection: keep-alive
date: Wed, 02 Jan 2019 13:28:38 GMT
authorization: OSS qn6qrrqxo2oawuk53otfjbyc:zUglwRPGkbByZxm1+y4eyu+NIUs=zV0****
Content-Length: 0
返回示例
HTTP/1.1 204 No Content
Server: AliyunOSS
Date: Wed, 02 Jan 2019 13:28:38 GMT
Content-Length: 0
Connection: keep-alive
x-oss-request-id: 5C2CBC8653718B5511EF4535
x-oss-server-time: 134

SDK

DeleteObject接口所对应的各语言SDK如下:

错误码

错误码 HTTP 状态码 描述
Not Found 404 目标Bucket不存在。
No Content 204 目标Object不存在。