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中文网2017-04-10 14:58:08
后台使用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