首页 > 后端开发 > php教程 > javascript - 七牛的上传凭证的uptoken应该怎么获取

javascript - 七牛的上传凭证的uptoken应该怎么获取

WBOY
发布: 2016-06-06 20:38:02
原创
1607 人浏览过

scope = 'my-bucket:sunflower.jpg'
deadline = 1451491200
returnBody = '{
"name": $(fname),
"size": $(fsize),
"w": $(imageInfo.width),
"h": $(imageInfo.height),
"hash": $(etag)
}'
putPolicy = '{"scope":"my-bucket:sunflower.jpg","deadline":1451491200,"returnBody":"{\"name\":$(fname),\"size\":$(fsize),\"w\":$(imageInfo.width),\"h\":$(imageInfo.height),\"hash\":$(etag)}"}'
encodedPutPolicy = urlsafe_base64_encode(putPolicy)
sign = hmac_sha1(encodedPutPolicy, "")
encodedSign = "wQ4ofysef1R7IKnrziqtomqyDvI="
uploadToken = AccessKey + ':' + encodedSign + ':' + encodedPutPolicy
我用html提交图片,上传到http://upload.qiniu.com/,后台用php,
我该怎么搭建后端,怎么通过ajax来获取uptoken,是在是看不懂这个api

回复内容:

scope = 'my-bucket:sunflower.jpg'
deadline = 1451491200
returnBody = '{
"name": $(fname),
"size": $(fsize),
"w": $(imageInfo.width),
"h": $(imageInfo.height),
"hash": $(etag)
}'
putPolicy = '{"scope":"my-bucket:sunflower.jpg","deadline":1451491200,"returnBody":"{\"name\":$(fname),\"size\":$(fsize),\"w\":$(imageInfo.width),\"h\":$(imageInfo.height),\"hash\":$(etag)}"}'
encodedPutPolicy = urlsafe_base64_encode(putPolicy)
sign = hmac_sha1(encodedPutPolicy, "")
encodedSign = "wQ4ofysef1R7IKnrziqtomqyDvI="
uploadToken = AccessKey + ':' + encodedSign + ':' + encodedPutPolicy
我用html提交图片,上传到http://upload.qiniu.com/,后台用php,
我该怎么搭建后端,怎么通过ajax来获取uptoken,是在是看不懂这个api

后台使用php的话,七牛的php-sdk中直接就给出了上传凭证的整个生成过程,https://github.com/qiniu/php-sdk/blob/v6/qiniu/rs.php#L67,另外你可以直接参考上传demo,方便你的理解,https://github.com/qiniu/php-sdk/blob/v6/demo/up.php

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板