8
8
9
9
## 项目状态
10
10
11
- 当前版本` 0.4.0 ` 为测试版本。请商户的专业技术人员在使用时注意系统和软件的正确性和兼容性,以及带来的风险。
11
+ 当前版本` 0.4.1 ` 为测试版本。请商户的专业技术人员在使用时注意系统和软件的正确性和兼容性,以及带来的风险。
12
12
13
13
## 升级指引
14
14
27
27
在你的` build.gradle ` 文件中加入如下的依赖
28
28
29
29
``` groovy
30
- implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.4.0 '
30
+ implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.4.1 '
31
31
```
32
32
33
33
### Maven
@@ -37,7 +37,7 @@ implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.4.0'
37
37
<dependency >
38
38
<groupId >com.github.wechatpay-apiv3</groupId >
39
39
<artifactId >wechatpay-apache-httpclient</artifactId >
40
- <version >0.4.0 </version >
40
+ <version >0.4.1 </version >
41
41
</dependency >
42
42
```
43
43
@@ -246,7 +246,7 @@ try {
246
246
247
247
我们对上传的参数组装和签名逻辑进行了一定的封装,只需要以下几步:
248
248
249
- 1 . 使用` WechatPayUploadHttpPost ` 构造一个上传的` HttpPost ` ,需设置待上传文件的文件名,SHA256摘要,文件的输入流。
249
+ 1 . 使用` WechatPayUploadHttpPost ` 构造一个上传的` HttpPost ` ,需设置待上传文件的文件名,SHA256摘要,文件的输入流。在 ` 0.4.1 ` 及以上版本,支持设置媒体文件元信息。
250
250
2 . 通过` WechatPayHttpClientBuilder ` 得到的` HttpClient ` 发送请求。
251
251
252
252
示例请参考下列代码。
@@ -260,6 +260,7 @@ try (FileInputStream ins1 = new FileInputStream(file)) {
260
260
String sha256 = DigestUtils . sha256Hex(ins1);
261
261
try (InputStream ins2 = new FileInputStream (file)) {
262
262
HttpPost request = new WechatPayUploadHttpPost .Builder (uri)
263
+ // 如需直接设置媒体文件元信息,可使用withFile代替withImage
263
264
.withImage(file. getName(), sha256, ins2)
264
265
.build();
265
266
CloseableHttpResponse response1 = httpClient. execute(request);
0 commit comments