Skip to content

Commit e1af06b

Browse files
bump to 0.9.4
- feat: support the "Automatic serialization to FormData" usage for the file upload
1 parent d363d15 commit e1af06b

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# 变更历史
22

3+
## v0.9.4 (2025-05-08)
4+
5+
- 优化`文件上传API`功能,支持`Axios``Automatic serialization to FormData`用法,伪代码示例如下:
6+
```js
7+
wxpay.v3.merchant.media.upload.post({
8+
meta: JSON.stringify({ filename, sha256 }),
9+
file: fs.createReadStream(localfilepath),
10+
}, {
11+
meta: { filename, sha256 },
12+
headers: { 'Content-Type': 'multipart/form-data' },
13+
});
14+
```
15+
316
## v0.9.3 (2025-03-30)
417

518
- 优化`Rsa.encrypt``Rsa.decrypt` 第三参数放弃支持 `RSA_PKCS1_PADDING` 填充方案;

lib/decorator.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ class Decorator {
113113
static requestInterceptor() {
114114
return function signer(config) {
115115
const method = config.method.toUpperCase();
116-
const payload = JSON.stringify(
117-
// for media upload, while this instance had `meta` Object defined,
118-
// let's checking whether or nor the real `data` is a `multipart/form-data` compatible instance
119-
config.meta && utils.isProcessFormData(config.data) ? config.meta : config.data,
120-
);
116+
const payload = JSON.stringify(config.meta ? config.meta : config.data);
121117
const nonce = Formatter.nonce();
122118
const timestamp = Formatter.timestamp();
123119
// `getUri` should missing some paths whose were on `baseURL`
@@ -129,8 +125,6 @@ class Decorator {
129125
config.privateKey,
130126
);
131127

132-
// A community user(JAVA) was reported there, while it contains a duplicated 'Authorization' header(mean dup-values asof the HTTP spec),
133-
// The server side guns away with 500 status code. Let's force using the single calculated value anyway.
134128
Reflect.set(config, 'headers', AxiosHeaders.from(config.headers).set(
135129
'Authorization', Formatter.authorization(config.mchid, nonce, signature, timestamp, config.serial), true,
136130
));

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wechatpay-axios-plugin",
3-
"version": "0.9.3",
3+
"version": "0.9.4",
44
"description": "微信支付APIv2及v3 NodeJS SDK,支持CLI模式请求OpenAPI,支持v3证书下载,v2付款码支付、企业付款、退款,企业微信-企业支付-企业红包/向员工付款,v2&v3 Native支付、扫码支付、H5支付、JSAPI/小程序支付、合单支付...",
55
"main": "index.js",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)