Skip to content

Commit

Permalink
fix(upload): make sure to carry custom parameters, fix #802
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jun 23, 2021
1 parent 60b80c9 commit c4b22a2
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ dist
.npmrc
.cache

test/server/static
tests/server/static
tests/server/static/upload

.local
# local env files
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 🐛 Bug Fixes

- **Table** 修复分页抖动问题
- **Upload** 确保携带自定义参数

## 2.5.0(2021-06-20)

Expand Down
8 changes: 6 additions & 2 deletions src/utils/http/axios/Axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import axios from 'axios';
import qs from 'qs';
import { AxiosCanceler } from './axiosCancel';
import { isFunction } from '/@/utils/is';
import { cloneDeep } from 'lodash-es';
import { cloneDeep, omit } from 'lodash-es';
import { ContentTypeEnum } from '/@/enums/httpEnum';
import { RequestEnum } from '/@/enums/httpEnum';

Expand Down Expand Up @@ -136,8 +136,12 @@ export class VAxios {
formData.append(key, params.data[key]);
});
}

formData.append(params.name || 'file', params.file, params.filename);
const customParams = omit(params, 'file', 'filename', 'file');

Object.keys(customParams).forEach((key) => {
formData.append(key, customParams[key]);
});

return this.axiosInstance.request<T>({
...config,
Expand Down
Binary file removed tests/server/static/upload/11.jpg
Binary file not shown.
Binary file removed tests/server/static/upload/5ab46a3cN616bdc41.jpg
Binary file not shown.
Binary file removed tests/server/static/upload/5ac1bf5fN2522b9dc.jpg
Binary file not shown.
Binary file removed tests/server/static/upload/5c9ccca8a27f0.png
Binary file not shown.
Binary file removed tests/server/static/upload/5c9ccca8b27f1.jpg
Binary file not shown.
Binary file removed tests/server/static/upload/5c9ccca8bc1e0.png
Binary file not shown.

0 comments on commit c4b22a2

Please sign in to comment.