Skip to content

Commit b3139fb

Browse files
committed
add fetch func
1 parent 1cd5b78 commit b3139fb

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

fetch.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
require_once('qiniu/rs.php');
4+
require_once('qiniu/conf.php');
5+
6+
$client = new Qiniu_MacHttpClient(null);
7+
$ret = Qiniu_RS_Fetch($client, 'http://img0.bdstatic.com/img/image/shouye/mxjxx-11768363916.jpg', 'alibaba', 'wf.jpg');
8+
9+
var_dump($ret);
10+

qiniu/conf.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$QINIU_RS_HOST = 'http://rs.qbox.me';
1515
$QINIU_RSF_HOST = 'http://rsf.qbox.me';
1616
$QINIU_API_HOST = 'http://api.qiniu.com';
17+
$QINIU_IOVIP_HOST = 'http://iovip.qbox.me';
1718

1819
$QINIU_ACCESS_KEY = '<Please apply your access key>';
1920
$QINIU_SECRET_KEY = '<Dont send your secret key to anyone>';

qiniu/rs.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,5 +254,16 @@ function Qiniu_RS_BatchCopy($self, $entryPairs)
254254
return Qiniu_RS_Batch($self, $params);
255255
}
256256

257+
// ----------------------------------------------------------
258+
// fetch
259+
function Qiniu_RS_Fetch($self, $url, $bucket, $key)
260+
{
261+
262+
global $QINIU_IOVIP_HOST;
263+
$path = '/fetch/' . Qiniu_Encode($url) . '/to/' . Qiniu_Encode("$bucket:$key");
264+
return Qiniu_Client_CallNoRet($self, $QINIU_IOVIP_HOST . $path);
265+
}
266+
267+
257268
// ----------------------------------------------------------
258269

up_demo.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
require_once('qiniu/io.php');
44
require_once('qiniu/rs.php');
55

6-
$bucket = 'auditlog';
6+
$bucket = 'alibaba';
77
$key1 = 'rwf';
8-
$file = '../php-sdk/1.mp4';
8+
$file = 'up_demo.php';
99

1010

1111
$client = new Qiniu_MacHttpClient(null);
1212
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
13+
$putPolicy->Scope = "$bucket:$key1";
14+
$putPolicy->EndUser = 'fuck';
1315
$upToken = $putPolicy->Token(null);
1416

1517
$putExtra = new Qiniu_PutExtra();

up_demo2.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)