Skip to content

Commit

Permalink
fix(server): Close file on upload and remove all files from form when…
Browse files Browse the repository at this point in the history
… PUT request is finished
  • Loading branch information
oxyno-zeta committed Jun 19, 2023
1 parent a9bf61f commit e0eec94
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/s3-proxy/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ func (svr *Server) generateRouter() (http.Handler, error) {

return
}

// Parse multipart form
err = req.ParseMultipartForm(0)
if err != nil {
Expand All @@ -407,6 +408,11 @@ func (svr *Server) generateRouter() (http.Handler, error) {

return
}
// Defer close file
defer file.Close()
// Defer remove all form
defer req.MultipartForm.RemoveAll() //nolint: errcheck // Ignored

// Create input for put request
inp := &bucket.PutInput{
RequestPath: requestPath,
Expand Down

0 comments on commit e0eec94

Please # to comment.