商户上传反馈图片
商户上传反馈图片的接口。 将媒体图片进行二进制转换,得到的媒体图片二进制内容,在请求body中上传此二进制内容。 媒体图片只支持jpg、png、bmp格式,文件大小不能超过2M。
js
const { createReadStream } = require('fs')
const { basename } = require('path');
let localFilePath = '/path/to/merchant-image-file.jpg'
const stream = createReadStream(localFilePath)
const meta = {
filename: basename(localFilePath),
sha256: 'from upstream or local calculated',
}
const media = {
meta: JSON.stringify(meta),
file: stream,
}
wxpay.v3.merchantService.images.upload.post(media, {
meta,
headers: { 'Content-Type': 'multipart/form-data' },
})
.then(
({
data: {
media_id,
},
}) => ({
media_id,
})
)