Skip to content

Commit

Permalink
fix file path
Browse files Browse the repository at this point in the history
  • Loading branch information
alice890308 committed May 28, 2022
1 parent bda653d commit 5aecb04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/file/service/file_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
})
}

Expand Down

0 comments on commit 5aecb04

Please sign in to comment.