Google Cloud Storage 签名 URL 强制响应处置

sim*_*332 4 google-cloud-storage google-cloud-platform

使用 GCS 签名 url 功能 ( https://cloud.google.com/storage/docs/access-control/signed-urls )时遇到问题,并且想要强制响应内容处置。

我过去曾经使用过它一次,但现在我似乎无法让它工作,也找不到任何关于谷歌弃用此功能的文档。

我当前的示例网址:https://storage.googleapis.com/examplebucket/examplefile.pdf ?GoogleAccessId=account&Expires=expire&Signature=xx& response-content-disposition=inline

签名正在工作,我可以访问该文件,只是无法强制处置。

如果我将文件上传为 Content-Disposition=attachment,那么它不会使其内联,反之亦然。

有任何想法吗?

Bra*_*ugh 7

对于签名 URL,contentDisposition 元数据属性(如果指定)将覆盖 response-content-disposition 查询参数。这是因为响应内容处置查询参数不是签名的一部分,这意味着最终用户可以更改它。

如果要在签名 URL 中指定response-content-disposition,请清除 contentDisposition 元数据属性,然后将使用查询参数中的值。