是否可以从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.
推荐答案
另一种方法(如果您说不介意从外部获取令牌)是使用curl来设置对GCS的调用中的授权"标头像这样:
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
直接下载对象数据而不是接收JSON响应时,必须使用'alt = media'查询字符串参数.
The 'alt=media' query string parameter is necessary to download the object data directly instead of receiving a JSON response.
您可以分别将通过Cloud Storage JSON API授权获得的令牌复制并粘贴到 OAuth 2.0 Playground .
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-control
https://cloud.google.com/storage/docs/json_api/v1 /objects/get
See also:
https://cloud.google.com/storage/docs/access-control
https://cloud.google.com/storage/docs/json_api/v1/objects/get
这篇关于是否可以从GCS中获取/卷曲受保护的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!