/** * 列取空间的文件列表 * * @param $bucket 空间名 * @param $prefix 列举前缀 * @param $marker 列举标识符 * @param $limit 单次列举个数限制 * @param $delimiter 指定目录分隔符 * * @return array 包含文件信息的数组,类似:[ * { * "hash" => "<Hash string>", * "key" => "<Key string>", * "fsize" => "<file size>", * "putTime" => "<file modify time>" * }, * ... * ] * @link http://developer.qiniu.com/docs/v6/api/reference/rs/list.html */ public function listFiles($bucket, $prefix = null, $marker = null, $limit = 1000, $delimiter = null) { $query = array('bucket' => $bucket); \Qiniu\setWithoutEmpty($query, 'prefix', $prefix); \Qiniu\setWithoutEmpty($query, 'marker', $marker); \Qiniu\setWithoutEmpty($query, 'limit', $limit); \Qiniu\setWithoutEmpty($query, 'delimiter', $delimiter); $url = Config::RSF_HOST . '/list?' . http_build_query($query); list($ret, $error) = $this->get($url); if ($ret === null) { return array(null, null, $error); } $marker = array_key_exists('marker', $ret) ? $ret['marker'] : null; return array($ret['items'], $marker, null); }
/** * 对资源文件进行异步持久化处理 * * @param $key 待处理的源文件 * @param $fops string|array 待处理的pfop操作,多个pfop操作以array的形式传入。 * eg. avthumb/mp3/ab/192k, vframe/jpg/offset/7/w/480/h/360 * * @return array 返回持久化处理的persistentId, 和返回的错误。 * * @link http://developer.qiniu.com/docs/v6/api/reference/fop/ */ public function execute($key, $fops) { if (is_array($fops)) { $fops = implode(';', $fops); } $params = array('bucket' => $this->bucket, 'key' => $key, 'fops' => $fops); \Qiniu\setWithoutEmpty($query, 'pipeline', $this->pipeline); \Qiniu\setWithoutEmpty($query, 'notifyURL', $this->notify_url); if ($this->force) { $params['force'] = 1; } $data = http_build_query($params); $url = Config::API_HOST . '/pfop/'; $headers = $this->auth->authorization($url, $data, 'application/x-www-form-urlencoded'); $headers['Content-Type'] = 'application/x-www-form-urlencoded'; $response = Client::post($url, $data, $headers); if (!$response->ok()) { return array(null, new Error($url, $response)); } $r = $response->json(); $id = $r['persistentId']; return array($id, null); }