From 4c46bdaa7f00bc2867ef4e0fee4a7d9fc157995e Mon Sep 17 00:00:00 2001 From: 3vilive Date: Fri, 27 Sep 2024 20:54:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=88=B0=20oss=20=E9=81=87=E5=88=B0=E9=94=99=E8=AF=AF=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=BA=94=E8=AF=A5=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=20panic=20(#1890)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/api/v1/example/exa_file_upload_download.go | 4 ++-- server/service/example/exa_file_upload_download.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/api/v1/example/exa_file_upload_download.go b/server/api/v1/example/exa_file_upload_download.go index 330c8a79..6905936d 100644 --- a/server/api/v1/example/exa_file_upload_download.go +++ b/server/api/v1/example/exa_file_upload_download.go @@ -32,8 +32,8 @@ func (b *FileUploadAndDownloadApi) UploadFile(c *gin.Context) { } file, err = fileUploadAndDownloadService.UploadFile(header, noSave) // 文件上传后拿到文件路径 if err != nil { - global.GVA_LOG.Error("修改数据库链接失败!", zap.Error(err)) - response.FailWithMessage("修改数据库链接失败", c) + global.GVA_LOG.Error("上传文件失败!", zap.Error(err)) + response.FailWithMessage("上传文件失败", c) return } response.OkWithDetailed(exampleRes.ExaFileResponse{File: file}, "上传成功", c) diff --git a/server/service/example/exa_file_upload_download.go b/server/service/example/exa_file_upload_download.go index 85b7d338..cca3ec51 100644 --- a/server/service/example/exa_file_upload_download.go +++ b/server/service/example/exa_file_upload_download.go @@ -92,7 +92,7 @@ func (e *FileUploadAndDownloadService) UploadFile(header *multipart.FileHeader, oss := upload.NewOss() filePath, key, uploadErr := oss.UploadFile(header) if uploadErr != nil { - panic(uploadErr) + return file, uploadErr } s := strings.Split(header.Filename, ".") f := example.ExaFileUploadAndDownload{