uploadFile 获取上传链接之后,上传图片始终返回 MalformedPOSTRequest
发布于 5 年前 作者 xiahan 6782 次浏览 来自 问答

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>

返回链接的使用是否可以给个可用的示例
回到顶部