Skip to content

Commit

Permalink
fix: 新版axios 对上传文件的header有要求
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Feb 15, 2024
1 parent 2bfe0d2 commit 079dc6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/api/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default {
url: 'system/uploadImage',
method: 'post',
timeout: 30000,
headers: { 'Content-Type': 'multipart/form-data' },
data
})
},
Expand All @@ -118,6 +119,7 @@ export default {
url: 'system/uploadFile',
method: 'post',
timeout: 30000,
headers: { 'Content-Type': 'multipart/form-data' },
data
})
},
Expand All @@ -131,6 +133,7 @@ export default {
url: 'system/chunkUpload',
method: 'post',
timeout: 30000,
headers: { 'Content-Type': 'multipart/form-data' },
data
})
},
Expand Down Expand Up @@ -184,7 +187,7 @@ export default {
* 通用导入Excel
*/
importExcel (url, data) {
return request({ url, method: 'post', data, timeout: 30 * 1000 })
return request({ url, method: 'post', data, timeout: 30 * 1000, headers: { 'Content-Type': 'multipart/form-data' }, })
},

/**
Expand Down
5 changes: 4 additions & 1 deletion src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ function stringify (data) {
'Accept-Language': setting?.language || 'zh_CN',
'Content-Type': get(config, 'headers.Content-Type', 'application/json;charset=UTF-8')
},
config.header
config.headers
),

timeout: 10000,
data: {}
}

delete config.headers
// return
const option = Object.assign(configDefault, config)

// json
Expand Down

0 comments on commit 079dc6f

Please sign in to comment.