Skip to content

Commit

Permalink
optimize: file unexist error for binding
Browse files Browse the repository at this point in the history
  • Loading branch information
FGYFFFF committed Jun 11, 2024
1 parent 0fe1182 commit 6c12e89
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package decoder

import (
"fmt"
"github.com/cloudwego/hertz/pkg/common/hlog"
"reflect"

"github.com/cloudwego/hertz/pkg/protocol"
Expand Down Expand Up @@ -52,7 +53,8 @@ func (d *fileTypeDecoder) Decode(req *protocol.Request, params param.Params, req
}
file, err := req.FormFile(fileName)
if err != nil {
return fmt.Errorf("can not get file '%s', err: %v", fileName, err)
hlog.Warnf("can not get file '%s', err: %v. so skip", fileName, err)
return nil
}
if field.Kind() == reflect.Ptr {
t := field.Type()
Expand Down Expand Up @@ -105,11 +107,13 @@ func (d *fileTypeDecoder) fileSliceDecode(req *protocol.Request, params param.Pa
}
multipartForm, err := req.MultipartForm()
if err != nil {
return fmt.Errorf("can not get multipartForm info, err: %v", err)
hlog.Warnf("can not get MultipartForm, err: %v. so skip", fileName, err)
return nil
}
files, exist := multipartForm.File[fileName]
if !exist {
return fmt.Errorf("the file '%s' is not existed", fileName)
hlog.Warnf("the file '%s' is not existed, so skip", fileName)
return nil
}

if field.Kind() == reflect.Array {
Expand Down

0 comments on commit 6c12e89

Please sign in to comment.