Serving static files from google cloud storage?

前端 未结 2 1576
轮回少年
轮回少年 2020-12-10 06:54

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



        
相关标签:
2条回答
  • 2020-12-10 07:37

    I'm not sure how you are uploading your files and why the public read is not set correctly, but you could also change that through the Google Cloud Storage Manager. Simply locate the bucket and the file and click on the Share Publicly checkmark and you'll get the link.

    list of files in the bucket on cloud storage

    Or you can upload that file using the gsutil with public read right away:

    gsutil cp -a public-read custom.css gs://my_backet
    
    0 讨论(0)
  • 2020-12-10 07:50

    Beside of manually change each of the static files through Google Cloud Storage Manager you can also set your bucket to be publically viewable using gsutil:

    Use acl to set public-read on current bucket objects

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

    Use defacl to set as default for future uploads:

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

    The "shared publicly" check box will be then automatically checked for every files uploaded.

    For accessing bucket, make sure that you have enter an authorized id or email for the groups and users and a domain for the bucket permission otherwise you will get error message like:

    'DefAclCommand' object has no attribute 'continue_on_error'
    

    You can do also in Console or Using IAM roles.

    0 讨论(0)
提交回复
热议问题