Object接口 > 资源元信息查询 | ||||||||||||||||||||||||||||||||||||||||||||||||
仅获取资源的Metadata信息,不返回资源内容。 请求报文请求地址:
GET /stat/<EncodedEntryURI> HTTP/1.1 Host: rs.qiniu.com Authorization: QBox <AccessToken>
管理凭证方式
响应报文
如果请求成功,返回包含如下内容的JSON字符串 { "fsize": <FileSize int>, "hash": "", "mimeType": "", "type": "", "putTime": <PutTime int64> }
如果请求失败,返回包含如下内容的JSON字符串 { "error": "" }
示例
curl -i \ -H "Authorization: QBox QNJi_bYJlmO5LeY..." \ "http://rs.qiniu.com/stat/ZGVtbzoyMDEzLTAyLTA5LTA3LTM5LTIwLmpwZw=="
GET /stat/ZGVtbzoyMDEzLTAyLTA5LTA3LTM5LTIwLmpwZw== HTTP/1.1 User-Agent: curl/7.30.0 Host: rs.qiniu.com Accept: */* Authorization: QBox QNJi_bYJlmO5LeY08FfoNj9w_r72Vsn... 注意:要在Authorization头部的AccessToken前添加QBox和半角空格。
HTTP/1.1 200 OK Server: nginx/1.0.8 Date: Sun, 03 Nov 2013 14:01:28 GMT Content-Type: application/json Connection: keep-alive Cache-Control: no-store Content-Length: 121 X-Log: qtbl.get;RS X-Reqid: swEAAMipp-5bIjMT { "fsize": 5122935, "hash": "ljfockr0lOil_bZfyaI2ZY78HWoH", "mimeType": "application/octet-stream", "putTime": 13603956734587420 } 示例function fileDetail($accessKey,$secretKey,$bucket,$key) { $authObj = new Auth($accessKey, $secretKey); $http = new Http(); $encodedEntryURI = $authObj->entry($bucket, $key); $url = "http://rs.qiniu.com/stat/{$encodedEntryURI}"; $headers = $authObj->getHeaders($url, null, 'application/x-www-form-urlencoded'); // 创建一个新cURL资源 $curl = curl_init(); // 设置URL和相应的选项 curl_setopt($curl, CURLOPT_URL, $url); //CURLOPT_HEADER为true设置头文件的信息作为数据流输出 curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 60); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper('GET')); curl_setopt($curl, CURLOPT_POST, true); $result = curl_exec($curl); curl_close($curl); return $result; } $accessKey = 'xxx'; $secretKey = 'xxx'; $bucket = '123_1';//存储空间名称 $key = '123.png';//文件名 echo fileDetail($accessKey,$secretKey,$bucket,$key); |