From 8c5e6b48d03b326c7f0b7d5cc544cd087db919f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EC=A3=BC=ED=98=84?= Date: Tue, 25 Apr 2023 15:29:32 +0900 Subject: [PATCH] refactor: Replace Request.FormFile --- context.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/context.go b/context.go index 5716318e..4ec841fc 100644 --- a/context.go +++ b/context.go @@ -581,12 +581,12 @@ func (c *Context) FormFile(name string) (*multipart.FileHeader, error) { return nil, err } } - f, fh, err := c.Request.FormFile(name) - if err != nil { - return nil, err + if c.Request.MultipartForm != nil && c.Request.MultipartForm.File != nil { + if fhs := c.Request.MultipartForm.File[name]; len(fhs) > 0 { + return fhs[0], nil + } } - f.Close() - return fh, err + return nil, http.ErrMissingFile } // MultipartForm is the parsed multipart form, including file uploads.