Skip to content
Merged

Demo #93

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions demo/download_token.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
require_once('../qiniu/utils.php');
require_once('../qiniu/auth_digest.php');

function dnToken($url, $expires = 3600)
{

$e = 'e=' . (time() + $expires);

$qry = parse_url($url, PHP_URL_QUERY);
if ($qry) {
$url .= '&' . $e;
} else {
$url .= '?' . $e;
}

$sign = Qiniu_Sign(null, $url);

return $url . '&token=' . $sign;
}

$url = 'http://sslayer.qiniudn.com/dive-into-golang.pptx';
echo dnToken($url);

echo "\n";
$url = 'http://sslayer.qiniudn.com/dive-into-golang.pptx?odconv/pdf';
echo dnToken($url);
8 changes: 3 additions & 5 deletions demo/up.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@

$bucket = 'rwxf';
$key = 'up.php';
$file = __FILE__;
$file = __FILE__; //path to local file


$client = new Qiniu_MacHttpClient(null);
$putPolicy = new Qiniu_RS_PutPolicy($bucket);
$putPolicy->Scope = "$bucket:$key";
$putPolicy = new Qiniu_RS_PutPolicy("$bucket:$key");
$putPolicy->CallbackUrl = 'https://10fd05306325.a.passageway.io';
$putPolicy->CallbackBody = 'key=$(key)&hash=$(etag)';
$upToken = $putPolicy->Token(null);

$putExtra = new Qiniu_PutExtra();
$putExtra->Crc32 = 1;
$s = time();
list($ret, $err) = Qiniu_PutFile($upToken, $key, $file, $putExtra);
echo "time elapse:". (time() - $s) . "\n";
echo "\n\n====> Qiniu_PutFile result: \n";
echo "====> Qiniu_PutFile result: \n";
if ($err !== null) {
var_dump($err);
} else {
Expand Down