How do you get or generate a URL to the object in a bucket?

后端 未结 2 608
遥遥无期
遥遥无期 2020-12-29 05:16

I\'m storing objects in buckets on google cloud storage. I would like to provide a http url to the object for download. Is there a standard convention or way to expose files

相关标签:
2条回答
  • 2020-12-29 05:45

    Yes. Assuming that the objects are publicly accessible:

    http://BUCKET_NAME.storage.googleapis.com/OBJECT_NAME
    

    You can also use:

    http://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME
    

    Both HTTP and HTTPS work fine. Note that the object must be readable by anonymous users, or else the download will fail. More documentation is available at https://developers.google.com/storage/docs/reference-uris

    If it is the case that the objects are NOT publicly accessible and you only want the one user to be able to access them, you can generate a signed URL that will allow only the holder of the URL to download the object, and even then only for a limited period of time. I recommend using one of the GCS client libraries for this, as it's easy to get the signing code slightly wrong: https://developers.google.com/storage/docs/accesscontrol#Signed-URLs

    0 讨论(0)
  • 2020-12-29 05:48

    One way is to use https://storage.cloud.google.com// see more documentation at https://developers.google.com/storage/docs/collaboration#browser

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