1
0
mirror of synced 2026-04-09 01:49:20 +08:00

🆕 #3871 【微信支付】增加视频上传接口

This commit is contained in:
Copilot
2026-01-31 00:53:44 +08:00
committed by GitHub
parent dec6792333
commit 780c24bda0
5 changed files with 150 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package com.github.binarywang.wxpay.service.impl;
import com.github.binarywang.wxpay.bean.media.ImageUploadResult;
import com.github.binarywang.wxpay.bean.media.VideoUploadResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.MerchantMediaService;
import com.github.binarywang.wxpay.service.WxPayService;
@@ -51,4 +52,45 @@ public class MerchantMediaServiceImplTest {
log.info("mediaId2[{}]",mediaId2);
}
@Test
public void testVideoUploadV3() throws WxPayException, IOException {
MerchantMediaService merchantMediaService = new MerchantMediaServiceImpl(wxPayService);
String filePath = "你的视频文件的路径地址";
// String filePath = "WxJava/test-video.mp4";
File file = new File(filePath);
VideoUploadResult videoUploadResult = merchantMediaService.videoUploadV3(file);
String mediaId = videoUploadResult.getMediaId();
log.info("视频上传成功mediaId[{}]", mediaId);
VideoUploadResult videoUploadResult2 = merchantMediaService.videoUploadV3(file);
String mediaId2 = videoUploadResult2.getMediaId();
log.info("视频上传成功2mediaId2[{}]", mediaId2);
}
@Test
public void testVideoUploadV3WithInputStream() throws WxPayException, IOException {
MerchantMediaService merchantMediaService = new MerchantMediaServiceImpl(wxPayService);
String filePath = "你的视频文件的路径地址";
// String filePath = "WxJava/test-video.mp4";
File file = new File(filePath);
try (java.io.FileInputStream inputStream = new java.io.FileInputStream(file)) {
VideoUploadResult videoUploadResult = merchantMediaService.videoUploadV3(inputStream, file.getName());
String mediaId = videoUploadResult.getMediaId();
log.info("通过InputStream上传视频成功mediaId[{}]", mediaId);
}
}
}