fetch() public method

从指定URL抓取资源,并将该资源存储到指定空间中
public fetch ( $url, $bucket, $key = null ) : array
$url 指定的URL
$bucket 目标资源空间
$key 目标资源文件名
return array 包含已拉取的文件信息。 成功时: [ [ "hash" => "", "key" => "" ], null ] 失败时: [ null, Qiniu/Http/Error ]
Esempio n. 1
0
<?php

require_once __DIR__ . '/../autoload.php';
use Qiniu\Auth;
use Qiniu\Storage\BucketManager;
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);
$bmgr = new BucketManager($auth);
$url = 'http://php.net/favicon.ico';
$bucket = 'Bucket_Name';
$key = time() . '.ico';
list($ret, $err) = $bmgr->fetch($url, $bucket, $key);
echo "=====> fetch {$url} to bucket: {$bucket}  key: {$key}\n";
if ($err !== null) {
    var_dump($err);
} else {
    echo 'Success';
}
Esempio n. 2
0
 public function fetchImage($url, $imageName)
 {
     $bucketMgr = new BucketManager($this->auth);
     return $bucketMgr->fetch($url, $this->bucket, $imageName);
 }