问题描述
使用GCS签名网址功能( https://cloud.google.com/storage/docs/access-control/signed-urls ),并希望强制处理响应内容.
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.
我过去曾经使用过它,但是现在我似乎无法使它正常工作,并且找不到有关Google弃用此功能的任何文档.
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.
我当前的示例网址: https://storage.googleapis.com/examplebucket/examplefile.pdf?GoogleAccessId=account&Expires=expire&Signature=xx& response-content-disposition = inline
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.
如果我以Content-Disposition = attachment的形式上传文件,则它将不会内联,反之亦然.
If I upload file as Content-Disposition=attachment, then it wont make it inline and vice versa.
有什么想法吗?
推荐答案
对于已签名的URL,contentDisposition元数据属性(如果已指定)将覆盖response-content-disposition查询参数.这是因为response-content-disposition查询参数不是签名的一部分,这意味着最终用户可以更改它.
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.
如果要在签名的URL中指定response-content-disposition,请清除contentDisposition元数据属性,并使用查询参数中的值.
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.
这篇关于Google Cloud Storage签名URL强制响应处置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!