From 9f24ca5d66dfe96129bf100dd83b7edd8cf6b93d Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Tue, 27 May 2025 23:18:26 +0800 Subject: [PATCH] fix: empty fileName cause Reader nil for PostPolicyBucketHandler (#21323) --- cmd/bucket-handlers.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index b67b7c36a..21231d397 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -1089,6 +1089,14 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h break } + // check if have a file + if reader == nil { + apiErr := errorCodes.ToAPIErr(ErrMalformedPOSTRequest) + apiErr.Description = fmt.Sprintf("%s (%v)", apiErr.Description, errors.New("The file or text content is missing")) + writeErrorResponse(ctx, w, apiErr, r.URL) + return + } + if keyName, ok := formValues["Key"]; !ok { apiErr := errorCodes.ToAPIErr(ErrMalformedPOSTRequest) apiErr.Description = fmt.Sprintf("%s (%v)", apiErr.Description, errors.New("The name of the uploaded key is missing"))