Exemplo n.º 1
0
 /**
  * 从指定URL抓取资源,并将该资源存储到指定空间中
  *
  * @param $url        指定的URL
  * @param $bucket     目标资源空间
  * @param $key        目标资源文件名
  *
  * @return array    包含已拉取的文件信息。
  *                         成功时:  [
  *                                          [
  *                                              "hash" => "<Hash string>",
  *                                              "key" => "<Key string>"
  *                                          ],
  *                                          null
  *                                  ]
  *
  *                         失败时:  [
  *                                          null,
  *                                         Qiniu/Http/Error
  *                                  ]
  * @link  http://developer.qiniu.com/docs/v6/api/reference/rs/fetch.html
  */
 public function fetch($url, $bucket, $key = null)
 {
     $resource = Qiniu\base64_urlSafeEncode($url);
     $to = Qiniu\entry($bucket, $key);
     $path = '/fetch/' . $resource . '/to/' . $to;
     return $this->ioPost($path);
 }
Exemplo n.º 2
0
 private function fileUrl()
 {
     $url = $this->host . '/mkfile/' . $this->size;
     $url .= '/mimeType/' . Qiniu\base64_urlSafeEncode($this->mime);
     if ($this->key != null) {
         $url .= '/key/' . Qiniu\base64_urlSafeEncode($this->key);
     }
     if (!empty($this->params)) {
         foreach ($this->params as $key => $value) {
             $val = Qiniu\base64_urlSafeEncode($value);
             $url .= "/{$key}/{$val}";
         }
     }
     return $url;
 }
Exemplo n.º 3
0
 public function signWithData($data)
 {
     $data = Qiniu\base64_urlSafeEncode($data);
     return $this->sign($data) . ':' . $data;
 }