Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storage): add content type, disposition and encoding in v4 storage post policy #2769

Merged
merged 9 commits into from
Sep 17, 2020
3 changes: 0 additions & 3 deletions storage/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ func TestPostPolicyV4Conformance(t *testing.T) {
for _, testFile := range testFiles {
for _, tc := range testFile.PostPolicyV4Tests {
t.Run(tc.Description, func(t *testing.T) {
if tc.Description == "POST Policy With Additional Metadata" {
t.Skip("https://github.com/googleapis/google-cloud-go/issues/2767")
}
pin := tc.PolicyInput
utcNow = func() time.Time {
return time.Unix(pin.GetTimestamp().GetSeconds(), 0).UTC()
Expand Down
10 changes: 8 additions & 2 deletions storage/post_policy_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,16 @@ func GenerateSignedPostPolicyV4(bucket, object string, opts *PostPolicyV4Options
conds := make([]PostPolicyV4Condition, len(opts.Conditions))
copy(conds, opts.Conditions)
conds = append(conds,
conditionRedirectToURLOnSuccess(descFields.RedirectToURLOnSuccess),
conditionStatusCodeOnSuccess(descFields.StatusCodeOnSuccess),
// These are ordered lexicographically. Technically the order doesn't matter
// for creating the policy, but we use this order to match the
// cross-language conformance tests for this feature.
&singleValueCondition{"acl", descFields.ACL},
&singleValueCondition{"cache-control", descFields.CacheControl},
&singleValueCondition{"content-disposition", descFields.ContentDisposition},
&singleValueCondition{"content-encoding", descFields.ContentEncoding},
&singleValueCondition{"content-type", descFields.ContentType},
conditionRedirectToURLOnSuccess(descFields.RedirectToURLOnSuccess),
conditionStatusCodeOnSuccess(descFields.StatusCodeOnSuccess),
)

YYYYMMDD := now.Format(yearMonthDay)
Expand Down