uni-app 在给微信需要固定ip发送图片时,总是找不到参数
uni-app 在给微信需要固定ip发送图片时,总是找不到参数
示例代码:
.
操作步骤:
.
预期结果:
.
实际结果:
.
bug描述:
'use strict';
const fs = require('fs')
const path = require('path')
const FormData = require('form-data');
exports.main = async (event, context) => {
const form = new FormData();
const { filename, contentType, buffer } = await resolveFile(
event.thumb
);
form.append("media", buffer, {
filename,
contentType,
});
const res = await uniCloud.httpclient.request('https://api.weixin.qq.com/cgi-bin/material/add_material?type=image&access_token=123', {
method: 'POST',
content: form.getBuffer(),
headers: form.getHeaders(),
dataType: 'json'
})
return res
};
const images = await uniCloud.httpProxyForEip.postForm(
`https://api.weixin.qq.com/cgi-bin/material/add_material?type=image&access_token=${token.data[0].authorizer_access_token}`,
form.getBuffer(),
form.getHeaders()
);
但是一直错误"body": “{“errcode”:41005,“errmsg”:“media data missing hint: [Z1Apna0212p504] rid: 66f3d2ab-6735de3e-41e14703”}”,
2 回复
阿里云提供的固定ip方案不支持post formdata类型,这个postForm方法对应的body是application/x-www-form-urlencoded类型,你这个需求建议使用另外两个云厂商的云函数