1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-14 11:20:40 +00:00

add MaxUploadFile to provide more safety uploading controll

This commit is contained in:
Ming Deng
2020-10-20 22:06:24 +08:00
parent f9075e8274
commit d26683799a
3 changed files with 23 additions and 10 deletions

View File

@ -423,8 +423,7 @@ func (input *BeegoInput) SetData(key, val interface{}) {
// ParseFormOrMultiForm parseForm or parseMultiForm based on Content-type
func (input *BeegoInput) ParseFormOrMultiForm(maxMemory int64) error {
// Parse the body depending on the content type.
input.Context.Request.Body = http.MaxBytesReader(input.Context.ResponseWriter, input.Context.Request.Body, maxMemory)
if strings.Contains(input.Header("Content-Type"), "multipart/form-data") {
if input.IsUpload() {
if err := input.Context.Request.ParseMultipartForm(maxMemory); err != nil {
return errors.New("Error parsing request body:" + err.Error())
}