diff --git a/gin/request/util.go b/gin/request/util.go index 60460e0..48b5f02 100644 --- a/gin/request/util.go +++ b/gin/request/util.go @@ -10,12 +10,11 @@ package request import ( "encoding/json" "io" + "mime/multipart" "net/http" "net/url" "strings" - "git.zhangdeman.cn/zhangdeman/gopkg/util" - "github.com/gin-gonic/gin" ) @@ -187,15 +186,17 @@ func ParsePostRequestForFormData(ctx *gin.Context) (map[string]interface{}, erro var ( err error result map[string]interface{} + tmp *multipart.Form ) - if err = ctx.Request.ParseMultipartForm(32 << 20); nil != err { + + if tmp, err = ctx.MultipartForm(); nil != err { return make(map[string]interface{}), err } - if err = ctx.Request.ParseForm(); nil != err { - return make(map[string]interface{}), err - } - if err = util.JSONUnmarshalWithNumberForIOReader(ctx.Request.Body, &result); nil != err { - return make(map[string]interface{}), err + + result = make(map[string]interface{}) + for k, v := range tmp.Value { + result[k] = v } + return result, nil }