[#648] fix: Prevent InternalError response in PostObject handler
Signed-off-by: Nikita Zinkevich <n.zinkevich@yadro.com>
This commit is contained in:
parent
2c0a032966
commit
ffe91b43a1
2 changed files with 22 additions and 4 deletions
|
@ -498,7 +498,8 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
policy, err := checkPostPolicy(r, reqInfo, metadata)
|
||||
if err != nil {
|
||||
h.logAndSendError(ctx, w, "failed check policy", reqInfo, err)
|
||||
h.logAndSendError(ctx, w, "failed check policy", reqInfo,
|
||||
fmt.Errorf("%w: %v", apierr.GetAPIError(apierr.ErrInvalidArgument), err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -548,7 +549,8 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) {
|
|||
if reqInfo.ObjectName == "" || strings.Contains(reqInfo.ObjectName, "${filename}") {
|
||||
_, head, err := r.FormFile("file")
|
||||
if err != nil {
|
||||
h.logAndSendError(ctx, w, "could not parse file field", reqInfo, err)
|
||||
h.logAndSendError(ctx, w, "could not parse file field", reqInfo,
|
||||
fmt.Errorf("%w: %v", apierr.GetAPIError(apierr.ErrInvalidArgument), err))
|
||||
return
|
||||
}
|
||||
filename = head.Filename
|
||||
|
@ -557,7 +559,8 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) {
|
|||
var head *multipart.FileHeader
|
||||
contentReader, head, err = r.FormFile("file")
|
||||
if err != nil {
|
||||
h.logAndSendError(ctx, w, "could not parse file field", reqInfo, err)
|
||||
h.logAndSendError(ctx, w, "could not parse file field", reqInfo,
|
||||
fmt.Errorf("%w: %v", apierr.GetAPIError(apierr.ErrInvalidArgument), err))
|
||||
return
|
||||
}
|
||||
size = uint64(head.Size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue