问题描述
遇到问题,使用 GCS 签名 url 功能 (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
签名有效,我可以访问文件,只是无法强制处置.
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 强制响应处置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!