Home >Backend Development >PHP Tutorial >七牛云存储 - 七牛php-sdk回调问题

七牛云存储 - 七牛php-sdk回调问题

WBOY
WBOYOriginal
2016-06-06 20:35:111426browse

<code><?php require_once($_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php');

use Qiniu\Auth;

$accessKey = '9A2bjCYNsd1yYL6EMUD5fcIfEMoRj4H2OvgBwmjo';
$secretKey = 'lXCCmDAPpMOqvP-8Uj1jA-bwKLa2XH_007IfBWOa';
$auth = new Auth($accessKey, $secretKey);

$bucket = 'usa-cns';
// 设置put policy的其他参数
$opts = array(
    'callbackUrl' => 'http://songcharm.com/back',
    'callbackBody' => 'name=$(fname)&hash=$(etag)'
);
$token = $auth->uploadToken($bucket, null, 3600, $opts);
?>
</code>

这样的回调写法对吗?为什么我提交了上传表单,返回的还是upload.qiniu.com这个地址呢

回复内容:

<code><?php require_once($_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php');

use Qiniu\Auth;

$accessKey = '9A2bjCYNsd1yYL6EMUD5fcIfEMoRj4H2OvgBwmjo';
$secretKey = 'lXCCmDAPpMOqvP-8Uj1jA-bwKLa2XH_007IfBWOa';
$auth = new Auth($accessKey, $secretKey);

$bucket = 'usa-cns';
// 设置put policy的其他参数
$opts = array(
    'callbackUrl' => 'http://songcharm.com/back',
    'callbackBody' => 'name=$(fname)&hash=$(etag)'
);
$token = $auth->uploadToken($bucket, null, 3600, $opts);
?>
</code>

这样的回调写法对吗?为什么我提交了上传表单,返回的还是upload.qiniu.com这个地址呢

这个回调的写法是正确的,你指的返回的是upload.qiniu.com地址具体是什么意思,设置了回调,七牛会post给 http://songcharm.com/back 这个url,上传文件的原始文件名(fname)和文件的hash(etag)值,你可以看下服务端是否接收到了七牛的回调。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn