Object接口 > 资源列举 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
描述本接口用于列举指定空间里的所有文件条目。 请求请求地址:
GET /list?bucket=<Bucket>&marker=<Marker>&limit=<Limit>&prefix=<UrlEncodedPrefix>&delimiter=<UrlEncodedDelimiter> HTTP/1.1 Host: rsf.qbox.me Content-Type: application/x-www-form-urlencoded Authorization: QBox <AccessToken>
该请求操作的实现使用了所有操作的公共请求头
该请求操作的请求体为空。 响应
该请求操作的实现使用了所有操作的公共响应头。
请求示例: 列出test空间下所有1开头的资源: GET /v2/list?bucket=test&prefix=1 HTTP/1.1 Host: rsf.qbox.me User-Agent: Go-http-client/1.1 Authorization: QBox j853F3bLkWl59I5BOkWm6q1Z1mZClpr9Z9CLfDE0:XvRh0ABLViTohBkgKqa0upyiug0= Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip 响应示例: HTTP/1.1 200 OK Content-Length: 739 Connection: keep-alive Content-Type: application/json Date: Wed, 22 Nov 2019 01:41:20 GMT Server: nginx X-Reqid: QBUAAKUcoGrgRPkU { "items": [ { "key": "10.pdf", "hash": "Fs3oFOyOFDUp5CEODM8J6xquSq3s", "fsize": 252580, "mimeType": "application/pdf", "putTime": 15112568720620784, "type": 0, "status": 0 }, { "key": "11.ico", "hash": "FpGrGHQOjETYnwxmSF3uXmFpmZIb", "fsize": 5656, "mimeType": "image/x-icon", "putTime": 15112568850754920, "type": 0, "status": 0 }, { "key": "12.png", "hash": "FreZ58OmkQe5ZRUktRsO3zoqRaHi", "fsize": 11041, "mimeType": "image/png", "putTime": 15112568948976712, "type": 0, "status": 0 }, { "key": "13.png", "hash": "FreZ58OmkQe5ZRUktRsO3zoqRaHi", "fsize": 20761, "mimeType": "image/png", "putTime": 15112569033603324, "type": 0, "status": 0 } ] } 示例function bucketFile($ak,$sk,$bucket,$marker,$limit,$prefix,$delimiter) { $authObj = new Auth($ak, $sk); $url = "http://rsf.qbox.me/v2/list?bucket={$bucket}&prefix={$prefix}&delimiter={$delimiter}&limit={$limit}&marker={$marker}"; $headers = $authObj->getHeaders($url, null, 'application/x-www-form-urlencoded'); $result = $http->send($url, 'GET', [], $headers); //状态码 print_r('http code:'.$http->getHttpCode()); 创建一个新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); $this->httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);//http状态码 curl_close($curl); return $result; } $ak = 'xxx'; $sk = 'xxx'; $bucket = '123_1'; //存储空间名称,要求在互站云对象存储范围内唯一,由3~63个字符组成,支持小写字母、短划线-和数字,且必须以小写字母或数字开头和结尾。 $marker = ''; //上一次列举返回的位置标记,作为本次列举的起点信息。默认值为空字符串。 $limit = 50; //本次列举的条目数,范围为1-1000。默认值为1000。 $prefix = ''; //指定前缀,只有资源名匹配该前缀的资源会被列出。默认值为空字符串。 $delimiter = ''; //指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。默认值为空字符串。 echo bucketFile($ak,$sk,$bucket,$marker,$limit,$prefix,$delimiter); |