From 4acfae712723fae025df6b841f9cc0e80c8ca464 Mon Sep 17 00:00:00 2001 From: Simon Kirsten <1972314+skirsten@users.noreply.github.com> Date: Fri, 21 Oct 2022 22:38:04 +0200 Subject: [PATCH] Allow empty contentTypeStartsWith in PostPolicy (#1710) --- functional_tests.go | 4 ---- post-policy.go | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/functional_tests.go b/functional_tests.go index 72f584850..7b7652811 100644 --- a/functional_tests.go +++ b/functional_tests.go @@ -4216,10 +4216,6 @@ func testPresignedPostPolicy() { logError(testName, function, args, startTime, "", "SetContentType did not fail for invalid conditions", err) return } - if err := policy.SetContentTypeStartsWith(""); err == nil { - logError(testName, function, args, startTime, "", "SetContentTypeStartsWith did not fail for invalid conditions", err) - return - } if err := policy.SetContentLengthRange(1024*1024, 1024); err == nil { logError(testName, function, args, startTime, "", "SetContentLengthRange did not fail for invalid conditions", err) return diff --git a/post-policy.go b/post-policy.go index 06bf78b69..3cd97c0eb 100644 --- a/post-policy.go +++ b/post-policy.go @@ -171,10 +171,8 @@ func (p *PostPolicy) SetContentType(contentType string) error { // SetContentTypeStartsWith - Sets what content-type of the object for this policy // based upload can start with. +// If "" is provided it allows all content-types. func (p *PostPolicy) SetContentTypeStartsWith(contentTypeStartsWith string) error { - if strings.TrimSpace(contentTypeStartsWith) == "" || contentTypeStartsWith == "" { - return errInvalidArgument("No content type specified.") - } policyCond := policyCondition{ matchType: "starts-with", condition: "$Content-Type",