From 9af4cad55246c416f4b40adb0e5a5e120e97ba50 Mon Sep 17 00:00:00 2001 From: preschooler Date: Sun, 28 Dec 2025 21:15:44 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=97=B6=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=20Content-Type=EF=BC=8C=E5=90=A6=E5=88=99=E4=BC=9A=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/UploadFile/src/useUpload.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/UploadFile/src/useUpload.ts b/src/components/UploadFile/src/useUpload.ts index 8f316eb59..dddd15961 100644 --- a/src/components/UploadFile/src/useUpload.ts +++ b/src/components/UploadFile/src/useUpload.ts @@ -1,5 +1,9 @@ import * as FileApi from '@/api/infra/file' -import { UploadRawFile, UploadRequestOptions, UploadProgressEvent } from 'element-plus/es/components/upload/src/upload' +import { + UploadRawFile, + UploadRequestOptions, + UploadProgressEvent +} from 'element-plus/es/components/upload/src/upload' import axios, { AxiosProgressEvent } from 'axios' /** @@ -19,7 +23,7 @@ export const useUpload = (directory?: string) => { // 文件上传进度监听 const uploadProgressHandler = (evt: AxiosProgressEvent) => { const upEvt: UploadProgressEvent = Object.assign(evt.event) - upEvt.percent = evt.progress ? (evt.progress * 100) : 0 + upEvt.percent = evt.progress ? evt.progress * 100 : 0 options.onProgress(upEvt) // 触发 el-upload 的 on-progress } @@ -33,7 +37,7 @@ export const useUpload = (directory?: string) => { return axios .put(presignedInfo.uploadUrl, options.file, { headers: { - 'Content-Type': options.file.type + 'Content-Type': options.file.type || 'application/octet-stream' }, onUploadProgress: uploadProgressHandler }) @@ -80,7 +84,7 @@ function createFile(vo: FileApi.FilePresignedUrlRespVO, file: UploadRawFile, fil url: vo.url, path: vo.path, name: fileName, - type: file.type, + type: file.type || 'application/octet-stream', size: file.size } FileApi.createFile(fileVo)