From ff14cf90f0839350eb45d6341d3474aa34293302 Mon Sep 17 00:00:00 2001 From: khalidlife Date: Tue, 30 Apr 2024 09:30:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(useUpload.ts):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0Content-T?= =?UTF-8?q?ype=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UploadFile/src/useUpload.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/UploadFile/src/useUpload.ts b/src/components/UploadFile/src/useUpload.ts index cadad9e9..c0465a28 100644 --- a/src/components/UploadFile/src/useUpload.ts +++ b/src/components/UploadFile/src/useUpload.ts @@ -17,7 +17,11 @@ export const useUpload = () => { // 1.2 获取文件预签名地址 const presignedInfo = await FileApi.getFilePresignedUrl(fileName) // 1.3 上传文件(不能使用 ElUpload 的 ajaxUpload 方法的原因:其使用的是 FormData 上传,Minio 不支持) - return axios.put(presignedInfo.uploadUrl, options.file).then(() => { + return axios.put(presignedInfo.uploadUrl, options.file, { + headers: { + 'Content-Type': options.file.type, + } + }).then(() => { // 1.4. 记录文件信息到后端(异步) createFile(presignedInfo, fileName, options.file) // 通知成功,数据格式保持与后端上传的返回结果一致