search

Home  >  Q&A  >  body text

javascript - 用了七牛自己生成uptoken的工具,不加returnBody不报错,加了官网的returnBody格式的上传凭证就报错无语了

这是已经JSON.stringify过的,不加returnBody的凭证
var putPolicy = '{'+

            '"saveKey":"$(etag)$(ext)",'+
            '"scope":"' + minxing.qiniu.scope + '",'+
            '"deadline":' + minxing.qiniu.deadline()+','+ 
            '"mimeLimit":"image/jpeg;image/png"}';

加密后的uptoken完全没问题

这是加了returnBody(还是官网自己写的样例),妈的已上传就 invalid put policy encoding
var putPolicy = '{'+

            '"saveKey":"$(etag)$(ext)",'+
            '"scope":"' + minxing.qiniu.scope + '",'+
            '"returnBody":"{\"key\": $(key), \"hash\": $(etag), \"w\": $(imageInfo.width), \"h\": $(imageInfo.height)}",'+
            '"deadline":' + minxing.qiniu.deadline()+','+ 
            '"mimeLimit":"image/jpeg;image/png"}';

我就服了。。。求大神指点下,我把returnBody换了各种方式均报错
1 '"returnBody":{\"key\": $(key), \"hash\": $(etag), \"w\": $(imageInfo.width), \"h\": $(imageInfo.height)},'+
2 '"returnBody":{\"key\": \"$(key)\", \"hash\": \"$(etag)\", \"w\": \"$(imageInfo.width)\", \"h\": \"$(imageInfo.height)\"},'+

都不行。。。

各种不行
1 var putPolicy = '{"saveKey":"$(etag)$(ext)","scope":"' + minxing.qiniu.scope + '","deadline":' + minxing.qiniu.deadline()+',"mimeLimit":"image/jpeg;image/png","returnBody":{\"key\":$(key)}}';

2 var putPolicy = '{"saveKey":"$(etag)$(ext)","scope":"' + minxing.qiniu.scope + '","deadline":' + minxing.qiniu.deadline()+',"mimeLimit":"image/jpeg;image/png","returnBody":{\"key\":\"$(key)\"}}';

3 var putPolicy = '{"saveKey":"$(etag)$(ext)","scope":"' + minxing.qiniu.scope + '","deadline":' + minxing.qiniu.deadline()+',"mimeLimit":"image/jpeg;image/png","returnBody":"{\"key\":$(key)}"}';

4 3 var putPolicy = '{"saveKey":"$(etag)$(ext)","scope":"' + minxing.qiniu.scope + '","deadline":' + minxing.qiniu.deadline()+',"mimeLimit":"image/jpeg;image/png","returnBody":"{\"key\":\"$(key)\"}"}';

PHP中文网PHP中文网2819 days ago412

reply all(1)I'll reply

  • 高洛峰

    高洛峰2017-04-10 16:03:45

    你参考下面博客,第三条returnbody参数,你拷贝到你的程序试试,不可以的话你去七牛页面提交工单吧
    http://blog.csdn.net/guoer9973/article/details/45916709

    reply
    0
  • Cancelreply