Skip to content

storage: content-type condition does not appear in generated V4 post policy #2767

@pierreis

Description

@pierreis

Client

Storage

Code

e.g.

opts := &storage.PostPolicyV4Options{
  GoogleAccessID: email,
  PrivateKey:     privateKey,
  Expires:        time.Now().Add(10*time.Minute),
  Fields: &storage.PolicyV4Fields{
    ContentType: "text/plain",
  },
}
googlePolicy, err := storage.GenerateSignedPostPolicyV4(c.config.GoogleUploadBucket, objectKey, opts)

Expected behavior

The provided Content-Type should be included as a condition in the signed policy, per https://cloud.google.com/storage/docs/xml-api/post-object.

Actual behavior

The provided Content-Type is not included in the signed policy. Example resulting policy:

{
  "URL": "https://storage.googleapis.com/mybucket/",
  "Fields": {
    "key": "myobject",
    "policy": "eyJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJteWJ1Y2tldCJ9LHsia2V5IjoibXlvYmplY3QifSx7IngtZ29vZy1kYXRlIjoiMjAyMDA4MjRUMTAyMjIwWiJ9LHsieC1nb29nLWNyZWRlbnRpYWwiOiJ0ZXN0QGR1bW15LmlhbS5nc2VydmljZWFjY291bnQuY29tLzIwMjAwODI0L2F1dG8vc3RvcmFnZS9nb29nNF9yZXF1ZXN0In0seyJ4LWdvb2ctYWxnb3JpdGhtIjoiR09PRzQtUlNBLVNIQTI1NiJ9XSwiZXhwaXJhdGlvbiI6IjIwMjAtMDgtMjRUMTA6MzI6MjBaIn0=",
    "x-goog-algorithm": "GOOG4-RSA-SHA256",
    "x-goog-credential": "test@dummy.iam.gserviceaccount.com/20200824/auto/storage/goog4_request",
    "x-goog-date": "20200824T102220Z",
    "x-goog-signature": "[redacted]"
  }
}

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions