我想知道这是可能到吗?我一直得到报错“The body of your POST request is not well-formed multipart/form-data.”
我用一个云函数计算所需要到Auth,返还这个Auth给微信小程序后我想直接用wx.uploadFile上传图片到COS。以下是我实际的代码
wx.uploadFile({
url: "https://bucketname-appid.cos.ap-guangzhou.myqcloud.com",
filePath: this.data.imgSrc, // 这个imgSrc看起来是这样的 http://tmp/wx06831dfa43ec02c8.tGEdCWwps.6OYqN...jHa01.jpg
name: 'file',
header: {
'Authorization': resData.data, // 这里的data看起来是这样的 q-sign-algorithm=sha1&q-ak=AKIDK1a...&q-sign-time=1538223445;1538222464&q-key-time=1538223445;1538222464&q-header-list=&q-url-param-list=&q-signature=23b157...
"Content-Type": "multipart/form-data",
'Host': "bucketname-appid.cos.ap-guangzhou.myqcloud.com"
},
success: function (uploadRes) {
console.log('ssss::: ', uploadRes)
},
fail: function (e) {
console.log('e', e)
}
});
**我用“bucketname-appid"代替了真实的bucketname和appid
这段代码会运行success中的callback,console.log显示如下
data:"?? MalformedPOSTRequest
?
The body of your POST request is not well-formed multipart/form-data.?
bucketname-appid.cos.ap-guangzhou.myqcloud.com?
NWJh....FiMTc=?
OGVm...gzMzdjOTA=???"
errMsg:"uploadFile:ok"
statusCode:400
本文网址:http://www.91bianli.com/weixinxiaochengxu/47122.html