mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 20:22:20 +08:00
Merge 04e75f471290907655a2e1c97005d9553241995b into 626d55b0c02937645c21774cacc021713de88604
This commit is contained in:
commit
848d4a26c6
@ -609,8 +609,12 @@ func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {
|
|||||||
|
|
||||||
// MultipartForm is the parsed multipart form, including file uploads.
|
// MultipartForm is the parsed multipart form, including file uploads.
|
||||||
func (c *Context) MultipartForm() (*multipart.Form, error) {
|
func (c *Context) MultipartForm() (*multipart.Form, error) {
|
||||||
err := c.Request.ParseMultipartForm(c.engine.MaxMultipartMemory)
|
if c.Request.MultipartForm == nil {
|
||||||
return c.Request.MultipartForm, err
|
if err := c.Request.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c.Request.MultipartForm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveUploadedFile uploads the form file to specific dst.
|
// SaveUploadedFile uploads the form file to specific dst.
|
||||||
|
@ -120,7 +120,7 @@ func TestContextMultipartForm(t *testing.T) {
|
|||||||
if assert.NoError(t, err) {
|
if assert.NoError(t, err) {
|
||||||
assert.NotNil(t, f)
|
assert.NotNil(t, f)
|
||||||
}
|
}
|
||||||
|
assert.Equal(t, c.PostForm("foo"), "bar")
|
||||||
assert.NoError(t, c.SaveUploadedFile(f.File["file"][0], "test"))
|
assert.NoError(t, c.SaveUploadedFile(f.File["file"][0], "test"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user