-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
添加微信支付视频上传接口 #3871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+150
−4
Merged
添加微信支付视频上传接口 #3871
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b90de5e
Initial plan
Copilot b733aa4
添加微信支付视频上传接口实现
Copilot 16561c2
重构代码消除重复逻辑,提取withMedia共用方法
Copilot 32e7de5
优化测试代码,复用File对象
Copilot 0e23226
Update weixin-java-pay/src/main/java/com/github/binarywang/wxpay/serv…
binarywang 867293e
修改作者标签为copilot并添加InputStream测试用例
Copilot 8f8586e
fix: 修复PR review comments
binarywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/media/VideoUploadResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.github.binarywang.wxpay.bean.media; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||
|
|
||
| /** | ||
| * 视频文件上传返回结果对象 | ||
| * | ||
| * @author copilot | ||
| */ | ||
| @NoArgsConstructor | ||
| @Data | ||
| public class VideoUploadResult { | ||
|
|
||
| public static VideoUploadResult fromJson(String json) { | ||
| return WxGsonBuilder.create().fromJson(json, VideoUploadResult.class); | ||
| } | ||
|
|
||
| /** | ||
| * 媒体文件标识 Id | ||
| * <p> | ||
| * 微信返回的媒体文件标识Id。 | ||
| * 示例值:6uqyGjGrCf2GtyXP8bxrbuH9-aAoTjH-rKeSl3Lf4_So6kdkQu4w8BYVP3bzLtvR38lxt4PjtCDXsQpzqge_hQEovHzOhsLleGFQVRF-U_0 | ||
| */ | ||
| @SerializedName("media_id") | ||
| private String mediaId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 void testImageUploadV3() throws WxPayException, IOException { | |
| 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); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| String mediaId2 = videoUploadResult2.getMediaId(); | ||
|
|
||
| log.info("视频上传成功2,mediaId2:[{}]", mediaId2); | ||
|
|
||
| } | ||
binarywang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @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); | ||
| } | ||
|
|
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.