Commit c4b22a225d0088d87be0c0068f543366312521db
1 parent
60b80c96
fix(upload): make sure to carry custom parameters, fix #802
Showing
9 changed files
with
9 additions
and
3 deletions
.gitignore
CHANGELOG.zh_CN.md
src/utils/http/axios/Axios.ts
@@ -5,7 +5,7 @@ import axios from 'axios'; | @@ -5,7 +5,7 @@ import axios from 'axios'; | ||
5 | import qs from 'qs'; | 5 | import qs from 'qs'; |
6 | import { AxiosCanceler } from './axiosCancel'; | 6 | import { AxiosCanceler } from './axiosCancel'; |
7 | import { isFunction } from '/@/utils/is'; | 7 | import { isFunction } from '/@/utils/is'; |
8 | -import { cloneDeep } from 'lodash-es'; | 8 | +import { cloneDeep, omit } from 'lodash-es'; |
9 | import { ContentTypeEnum } from '/@/enums/httpEnum'; | 9 | import { ContentTypeEnum } from '/@/enums/httpEnum'; |
10 | import { RequestEnum } from '/@/enums/httpEnum'; | 10 | import { RequestEnum } from '/@/enums/httpEnum'; |
11 | 11 | ||
@@ -136,8 +136,12 @@ export class VAxios { | @@ -136,8 +136,12 @@ export class VAxios { | ||
136 | formData.append(key, params.data[key]); | 136 | formData.append(key, params.data[key]); |
137 | }); | 137 | }); |
138 | } | 138 | } |
139 | - | ||
140 | formData.append(params.name || 'file', params.file, params.filename); | 139 | formData.append(params.name || 'file', params.file, params.filename); |
140 | + const customParams = omit(params, 'file', 'filename', 'file'); | ||
141 | + | ||
142 | + Object.keys(customParams).forEach((key) => { | ||
143 | + formData.append(key, customParams[key]); | ||
144 | + }); | ||
141 | 145 | ||
142 | return this.axiosInstance.request<T>({ | 146 | return this.axiosInstance.request<T>({ |
143 | ...config, | 147 | ...config, |
tests/server/static/upload/11.jpg deleted
100644 → 0
215 KB
tests/server/static/upload/5ab46a3cN616bdc41.jpg deleted
100644 → 0
114 KB
tests/server/static/upload/5ac1bf5fN2522b9dc.jpg deleted
100644 → 0
405 KB
tests/server/static/upload/5c9ccca8a27f0.png deleted
100644 → 0
2.68 KB
tests/server/static/upload/5c9ccca8b27f1.jpg deleted
100644 → 0
37.8 KB
tests/server/static/upload/5c9ccca8bc1e0.png deleted
100644 → 0
2.12 KB