Beispiel #1
0
 private function fileUrl()
 {
     $func = new Functions();
     $url = $this->host . '/mkfile/' . $this->size;
     $url .= '/mimeType/' . $func->base64_urlSafeEncode($this->mime);
     if ($this->key != null) {
         $url .= '/key/' . $func->base64_urlSafeEncode($this->key);
     }
     if (!empty($this->params)) {
         foreach ($this->params as $key => $value) {
             $val = $func->base64_urlSafeEncode($value);
             $url .= "/{$key}/{$val}";
         }
     }
     return $url;
 }
Beispiel #2
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)
 {
     $func = new Functions();
     $resource = $func->base64_urlSafeEncode($url);
     $to = $func->entry($bucket, $key);
     $path = '/fetch/' . $resource . '/to/' . $to;
     return $this->ioPost($path);
 }