https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-http-api/storage/uploadFile.html
const uploadFile = (params) => {
let data = new FormData();
data.append('key', params.key);
data.append('Signature', params.authorization)
data.append('x-cos-security-token', params.token)
data.append('x-cos-meta-fileid', params.cos_file_id)
data.append('file', fs.createReadStream(params.file))
return Axios.post(params.url, data, {
headers: data.getHeaders()
})
返回结果:
<Error>
<Code>MalformedPOSTRequest</Code>
<Message>The body of your POST request is not well-formed multipart/form-data.</Message>
<Resource>cos.ap-shanghai.myqcloud.com/xxxx-release-xxxx-1252096413/materials/1576903346170.png</Resource>
<RequestId>NWRmZGEyYjJfYTNiMDFjMDlfN2I0MV9hMWFkODA=</RequestId>
<TraceId>OGVmYzZiMmQzYjA2OWNhODk0NTRkMTBiOWVmMDAxODc0OWRkZjk0ZDM1NmI1M2E2MTRlY2MzZDhmNmI5MWI1OTczMmZiNDZmZjBmNTVjMGU4NTViNDhhYWVjNzNkNzI4NmExNjUwOTY4Y2Q1OWM1N2RhZmNjZmIxOTJkNTQzMWM=</TraceId>
</Error>
返回链接的使用是否可以给个可用的示例
return Axios.post(params.url, data.getBuffer(), { headers: data.getHeaders() })
data那要用data.getBuffer()
请问楼主解决这个问题了吗