Skip to content

Commit

Permalink
🩹 fix: Close File After SaveFileToStorage (gofiber#3197)
Browse files Browse the repository at this point in the history
* fix: close file after opening in SaveFileToStorage to prevent resource leaks

* ♻️ refactor: simplify file close logic

* Update ctx.go

---------

Co-authored-by: Juan Calderon-Perez <[email protected]>
  • Loading branch information
gopkg-dev and gaby authored Nov 12, 2024
1 parent dcdd2eb commit 2c7bdb9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ func (*DefaultCtx) SaveFileToStorage(fileheader *multipart.FileHeader, path stri
if err != nil {
return fmt.Errorf("failed to open: %w", err)
}
defer file.Close() //nolint:errcheck // not needed

content, err := io.ReadAll(file)
if err != nil {
Expand Down

0 comments on commit 2c7bdb9

Please sign in to comment.