首頁 >後端開發 >php教程 >uploadToken里的四个参数分别是什么意思?

uploadToken里的四个参数分别是什么意思?

WBOY
WBOY原創
2016-06-06 20:21:252240瀏覽

<code><?php require_once  'vendor/autoload.php';
header('Access-Control-Allow-Origin:*');

use Qiniu\Auth;

$bucket = 'devtest';
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);


//$upToken = $auth->uploadToken($bucket);

$policy = array(
    'returnUrl' => 'http://127.0.0.1/demo/simpleuploader/fileinfo.php',
    'returnBody' => '{"fname": $(fname)}',
);
$upToken = $auth->uploadToken($bucket, null, 3600, $policy);

echo $upToken;</code>

回复内容:

<code><?php require_once  'vendor/autoload.php';
header('Access-Control-Allow-Origin:*');

use Qiniu\Auth;

$bucket = 'devtest';
$accessKey = 'Access_Key';
$secretKey = 'Secret_Key';
$auth = new Auth($accessKey, $secretKey);


//$upToken = $auth->uploadToken($bucket);

$policy = array(
    'returnUrl' => 'http://127.0.0.1/demo/simpleuploader/fileinfo.php',
    'returnBody' => '{"fname": $(fname)}',
);
$upToken = $auth->uploadToken($bucket, null, 3600, $policy);

echo $upToken;</code>

uploadToken($bucket, null, 3600, $policy);
顺序依次是 空间,文件名,有效时长deadline,上传策略;
参考文档
http://developer.qiniu.com/docs/v6/api/reference/security/upload-token.html
http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn