是否可以从 GCS 获取/卷曲受保护的文件? [英] Is it possible to wget / curl protected files from GCS?
问题描述
是否可以在不公开的情况下从 Google Cloud Storage 获取/卷曲受保护的文件?我不介意固定的预定义令牌.我只是想避免我的公共文件被盗用,花费我很多钱.
Is it possible to wget / curl protected files from Google Cloud Storage without making them public? I don't mind a fixed predefined token. I just want to avoid the case where my public file gets leeched, costing me good dollars.
推荐答案
如果你说你不介意从外部获取令牌,另一种方法是在调用 GCS 时使用 curl 设置授权"标头像这样:
Another way, if as you say you don't mind getting a token externally, is to use curl to set the 'Authorization' header in your call to GCS like so:
curl -H "Authorization: Bearer 1/fFBGRNJru1FQd44AzqT3Zg" https://www.googleapis.com/storage/v1/b/bucket/o/object?alt=media
'alt=media' 查询字符串参数是直接下载对象数据而不是接收 JSON 响应所必需的.
The 'alt=media' query string parameter is necessary to download the object data directly instead of receiving a JSON response.
您可以在OAuth 2.0 Playground<中单独复制并粘贴通过Cloud Storage JSON API授权获得的令牌/a>.
You can copy and paste the token obtained by authorizing with the Cloud Storage JSON API separately in the OAuth 2.0 Playground.
另见:
https://cloud.google.com/storage/docs/access-controlhttps://cloud.google.com/storage/docs/json_api/v1/objects/get
这篇关于是否可以从 GCS 获取/卷曲受保护的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!