Browse Source

fix(upload): make sure to carry custom parameters, fix #802

pull/818/head
Vben 5 years ago
parent
commit
c4b22a225d
  1. 3
      .gitignore
  2. 1
      CHANGELOG.zh_CN.md
  3. 8
      src/utils/http/axios/Axios.ts
  4. BIN
      tests/server/static/upload/11.jpg
  5. BIN
      tests/server/static/upload/5ab46a3cN616bdc41.jpg
  6. BIN
      tests/server/static/upload/5ac1bf5fN2522b9dc.jpg
  7. BIN
      tests/server/static/upload/5c9ccca8a27f0.png
  8. BIN
      tests/server/static/upload/5c9ccca8b27f1.jpg
  9. BIN
      tests/server/static/upload/5c9ccca8bc1e0.png

3
.gitignore

@ -4,7 +4,8 @@ dist
.npmrc
.cache
test/server/static
tests/server/static
tests/server/static/upload
.local
# local env files

1
CHANGELOG.zh_CN.md

@ -3,6 +3,7 @@
### 🐛 Bug Fixes
- **Table** 修复分页抖动问题
- **Upload** 确保携带自定义参数
## 2.5.0(2021-06-20)

8
src/utils/http/axios/Axios.ts

@ -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';
@ -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,

BIN
tests/server/static/upload/11.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

BIN
tests/server/static/upload/5ab46a3cN616bdc41.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

BIN
tests/server/static/upload/5ac1bf5fN2522b9dc.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 KiB

BIN
tests/server/static/upload/5c9ccca8a27f0.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

BIN
tests/server/static/upload/5c9ccca8b27f1.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

BIN
tests/server/static/upload/5c9ccca8bc1e0.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Loading…
Cancel
Save