From 5aecb0438b266fd76e4bf02a8fe262be5e0c6854 Mon Sep 17 00:00:00 2001 From: Alice Date: Sat, 28 May 2022 18:00:13 +0800 Subject: [PATCH] fix file path --- modules/file/service/file_service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/file/service/file_service.go b/modules/file/service/file_service.go index 18779fe..94f8750 100644 --- a/modules/file/service/file_service.go +++ b/modules/file/service/file_service.go @@ -91,7 +91,7 @@ func (s *Service) Upload(c *gin.Context) { return } - filePath := "file/static/" + userID + "/" + uuid.New().String() + filePath := "static/" + userID + "/" + uuid.New().String() switch contentType { case "image/jpg": filePath += ".jpg" @@ -109,14 +109,14 @@ func (s *Service) Upload(c *gin.Context) { err = os.WriteFile(filePath, fileBytes, fs.FileMode(fileAuth)) if err != nil { c.JSON(http.StatusBadRequest, gin.H{ - "message": "write file error", + "message": err.Error(), }) return } c.JSON(http.StatusAccepted, gin.H{ "message": "success", - "filepath": filePath, + "filepath": "file/" + filePath, }) }