🩹 fix: Close File After SaveFileToStorage (#3197)

* 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 <835733+gaby@users.noreply.github.com>
pull/3204/head
Karen 2024-11-12 09:47:22 +08:00 committed by GitHub
parent dcdd2eb2c6
commit 2c7bdb9fd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 0 deletions

1
ctx.go
View File

@ -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 {