7

I wanted to serve static files stored in google cloud storage for app hosted in app engine. In HTML file, I used

<link href="https://storage.cloud.google.com/my_bucket/custom.css" rel="stylesheet">

It works properly, if the google account of logged in user has permission to access bucket. Since app can be accessed by anyone who will not have access to my bucket and in such case, static files will not be served.

Is it possible to make static files in bucket publicly available? I made static file(custom.css) as 'shared publicly'(ACL set to 'public-read') but still other users can't access it.

4

2 回答 2

7

我不确定您如何上传文件以及为什么未正确设置公共读取,但您也可以通过Google Cloud Storage Manager进行更改。只需找到存储桶和文件,然后单击Share Publicly复选标记,您将获得链接。

云存储桶中的文件列表

或者您可以使用或者您可以使用gsutil并立即公开阅读:

gsutil cp -a public-read custom.css gs://my_backet
于 2013-04-12T10:39:24.677 回答
1

除了通过Google Cloud Storage Manager手动更改每个静态文件之外,您还可以使用gsutil将存储桶设置为公开可见:

使用acl当前存储桶对象设置公开读取

gsutil -m acl set -R -a public-read gs://BUCKET_NAME

使用defacl设置为将来上传的默认值:

gsutil -m defacl set public-read gs://BUCKET_NAME

然后将自动检查每个上传的文件的“公开共享”复选框。

访问 bucket,请确保您已输入组和用户的授权 id 或电子邮件以及存储桶权限的域, 否则您将收到如下错误消息:

'DefAclCommand' object has no attribute 'continue_on_error'

您也可以在控制台使用 IAM 角色中进行。

于 2016-08-10T07:32:06.737 回答