Google Cloud Storage Signed URL forced response di

2019-07-26 23:45发布

问题:

Got a problem, using GCS signed url feature (https://cloud.google.com/storage/docs/access-control/signed-urls) and want to force response content disposition.

I've used it once before in the past, but now I cannot seem to get it work and cannot find any documentation about Google deprecating this feature.

My current example url: https://storage.googleapis.com/examplebucket/examplefile.pdf?GoogleAccessId=account&Expires=expire&Signature=xx&response-content-disposition=inline

Signing is working and I can reach the file, just cannot force disposition.

If I upload file as Content-Disposition=attachment, then it wont make it inline and vice versa.

Any ideas?

回答1:

For signed URLs, the contentDisposition metadata property, if specified, overrides the response-content-disposition query parameter. This is because the response-content-disposition query parameter is not part of the signature, which means that end users could change it.

If you want to specify response-content-disposition in the signed URL, clear the contentDisposition metadata property, and the value in the query parameter will be used.