Skip to content

Commit

Permalink
refine error log
Browse files Browse the repository at this point in the history
  • Loading branch information
minghsu0107 committed Mar 4, 2023
1 parent 031e751 commit 71ca0dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/uploader/http_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ func (r *HttpServer) UploadFiles(c *gin.Context) {
return
}
if err := c.Request.ParseMultipartForm(r.maxMemory); err != nil {
r.logger.Errorf("parse multipart form error: ", err)
r.logger.Errorf("error parsing multipart form into memory: %v", err)
response(c, http.StatusInternalServerError, common.ErrServer)
return
}
form, err := c.MultipartForm()
if err != nil {
r.logger.Error(err)
r.logger.Errorf("parse multipart form error: %v", err)
response(c, http.StatusBadRequest, ErrReceiveFile)
return
}
Expand All @@ -49,15 +49,15 @@ func (r *HttpServer) UploadFiles(c *gin.Context) {
for _, fileHeader := range fileHeaders {
f, err := fileHeader.Open()
if err != nil {
r.logger.Error(err)
r.logger.Errorf("error opening multipart file header: %v", err)
response(c, http.StatusBadRequest, ErrOpenFile)
return
}

extension := filepath.Ext(fileHeader.Filename)
newFileName := newObjectKey(channelID, extension)
if err := r.putFileToS3(c.Request.Context(), r.s3Bucket, newFileName, f); err != nil {
r.logger.Error(err)
r.logger.Errorf("error putting file to S3: %v", err)
response(c, http.StatusInternalServerError, ErrUploadFile)
return
}
Expand Down

0 comments on commit 71ca0dd

Please sign in to comment.