diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 4183a74a5..ae612cdbd 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -1116,9 +1116,10 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h Host: handlers.GetSourceIP(r), }) - if successRedirect != "" { - // Replace raw query params.. - redirectURL.RawQuery = getRedirectPostRawQuery(objInfo) + if redirectURL != nil { // success_action_redirect is valid and set. + redirectURL.Query().Add("bucket", objInfo.Bucket) + redirectURL.Query().Add("key", objInfo.Name) + redirectURL.Query().Add("etag", "\""+objInfo.ETag+"\"") writeRedirectSeeOther(w, redirectURL.String()) return } diff --git a/cmd/handler-utils.go b/cmd/handler-utils.go index b6d625637..4b3ba66eb 100644 --- a/cmd/handler-utils.go +++ b/cmd/handler-utils.go @@ -27,7 +27,6 @@ import ( "mime/multipart" "net/http" "net/textproto" - "net/url" "regexp" "strings" @@ -197,16 +196,6 @@ func extractMetadataFromMime(ctx context.Context, v textproto.MIMEHeader, m map[ return nil } -// The Query string for the redirect URL the client is -// redirected on successful upload. -func getRedirectPostRawQuery(objInfo ObjectInfo) string { - redirectValues := make(url.Values) - redirectValues.Set("bucket", objInfo.Bucket) - redirectValues.Set("key", objInfo.Name) - redirectValues.Set("etag", "\""+objInfo.ETag+"\"") - return redirectValues.Encode() -} - // Returns access credentials in the request Authorization header. func getReqAccessCred(r *http.Request, region string) (cred auth.Credentials) { cred, _, _ = getReqAccessKeyV4(r, region, serviceS3) diff --git a/cmd/post-policy_test.go b/cmd/post-policy_test.go index 3261118ff..4e9e250fa 100644 --- a/cmd/post-policy_test.go +++ b/cmd/post-policy_test.go @@ -447,7 +447,7 @@ func testPostPolicyBucketHandlerRedirect(obj ObjectLayer, instanceType string, t targetObj := keyName + "/upload.txt" // The url of success_action_redirect field - redirectURL, err := url.Parse("http://www.google.com") + redirectURL, err := url.Parse("http://www.google.com?query=value") if err != nil { t.Fatal(err) } @@ -499,7 +499,9 @@ func testPostPolicyBucketHandlerRedirect(obj ObjectLayer, instanceType string, t t.Error("Unexpected error: ", err) } - redirectURL.RawQuery = getRedirectPostRawQuery(info) + redirectURL.Query().Add("bucket", info.Bucket) + redirectURL.Query().Add("key", info.Name) + redirectURL.Query().Add("etag", "\""+info.ETag+"\"") expectedLocation := redirectURL.String() // Check the new location url