Skip to content

商户上传反馈图片

商户上传反馈图片的接口。 将媒体图片进行二进制转换,得到的媒体图片二进制内容,在请求body中上传此二进制内容。 媒体图片只支持jpg、png、bmp格式,文件大小不能超过2M。 官方文档

js
const { 
Multipart
} =
require
('wechatpay-axios-plugin')
const {
createReadStream
} =
require
('fs')
const {
basename
} =
require
('path');
let
localFilePath
= '/path/to/merchant-image-file.jpg'
const
stream
=
createReadStream
(
localFilePath
)
const
media
= new
Multipart
()
.
append
('meta',
JSON
.
stringify
({
filename
:
basename
(
localFilePath
),
sha256
: 'from upstream or local calculated',
})) .
append
('file',
stream
,
basename
(
localFilePath
))
wxpay
.
v3
.
merchantService
.
images
.
upload
.
post
(
media
)
.
then
(
({
data
: {
media_id
,
}, }) => ({
media_id
,
}) )

Released under the MIT License. (SITEMAP)