Object接口 > 资源删除 | ||||||||||||||||||||||||||||||
删除指定资源。如果资源不存在,则返回错误码612。 请求报文请求地址:
POST /delete/<EncodedEntryURI> HTTP/1.1 Host: rs.qiniu.com Content-Type: application/x-www-form-urlencoded Authorization: QBox <AccessToken>
管理凭证方式。
响应报文
HTTP/1.1 200 OK Content-Type: application/json Cache-Control: no-store
如果请求成功,不返回任何内容。 如果请求失败,返回包含如下内容的JSON字符串 { "error": "<errMsg string>", }
请求示例: POST /delete/bmV3ZG9jczpmaW5kX21hbi50eHQ= HTTP/1.1 User-Agent: curl/7.30.0 Host: rs.qbox.me Accept: */* Authorization: QBox u8WqmQu1jH21kxpIQmo2LqntzugM1VoHE9_pozCU:2LJIG... 响应示例: HTTP/1.1 200 OK Server: nginx/1.0.8 Date: Thu, 05 Dec 2013 06:55:29 GMT Content-Type: application/json Connection: keep-alive Content-Length: 0 X-Reqid: wxIAAD3btw-v3TwT 代码示例function deleteFile($accessKey, $secretKey,$bucket,$key) { $authObj = new Auth($accessKey, $secretKey); $http = new Http(); $entry = "{$bucket}:{$key}";//格式:空间名:文件名 $encodedEntryURI = $authObj->base64_urlSafeEncode($entry); $url = "http://rs.qiniu.com/delete/{$encodedEntryURI}"; $headers = $authObj->getHeaders($url); $result = $http->send($url,'POST',[],$headers); return $result; } $accessKey = 'xxx'; $secretKey = 'xxx'; $bucket = '123_1';//存储空间名称,要求在互站云对象存储范围内唯一,由3~63个字符组成,支持小写字母、短划线-和数字,且必须以小写字母或数字开头和结尾 $key = '123.png';//文件名 echo changeMime($accessKey,$secretKey,$bucket,$key); |