Skip to content

视频上传

部分微信支付业务指定商户需要使用图片上传 部分微信支付业务指定商户需要使用视频上传 API来上报视频信息,从而获得必传参数的值:视频MediaID 。 官方文档

js
const { 
Multipart
} =
require
('wechatpay-axios-plugin')
const {
createReadStream
} =
require
('fs')
const {
basename
} =
require
('path');
let
localFilePath
= '/path/to/merchant-video-file.mp4'
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
.
merchant
.
media
.
video_upload
.
post
(
media
)
.
then
(
({
data
: {
media_id
,
}, }) => ({
media_id
,
}) )

Released under the MIT License. (SITEMAP)