Google Cloud Storage hosted images don't show in my app

那年仲夏 提交于 2021-01-28 12:25:26

问题


I'm using Google Cloud Storage to store some images for my mobile app. All is good, I set my bucket to public and I can display images on my laptop web browser but I don't know why my mobile app doesn't show them.

The default link just doesn't work :

https://storage.cloud.google.com/xxxxxx/img.jpg

I've discovered a temporary fix. It works when i manually put the redirected link generated like this :

https://00e9e64bac5058e148f83f51ad2da7ad0739d5d15096126e97-apidata.googleusercontent.com/download/storage/v1/b/xxxxxxxxx/o/img.jpg?qk=AD5uMEto7ugE1khfN3VUxc12Mrtg543VNUPfu8Gsfh-Mg9IPe6nO9Y7g2CdJiWIY9ac4dlKpkNasIv40G3R1TD40ffBlTPB5uDb3crSaqx24BnyGX3TsuwFjMZQ3gkWzdZRSWAXpSuAo8Sph0gac4KG-O9BKcELKEVh-2Bxwm3dBYLv7NoRClyEkgtR1QriDRMfisidO2RULACR83xCl9ud0S39rZFw7mWQ7zeazrq_ruRocaNqwb3K69Cg7v2yaEoGA5wpt-QHMqzJgs3_fNlO3ZsxAC48kZpSjwn0ea1irK_C9CgoT1LfDwxrEEAXixr1IeIfXKnZAHq0ShK28oIWi6DRTxHWFPz2PQTPtsoP-tboxfIOwzuq0oxeX-mQtbs3-UGLdxTpxFLtn5jTYeFOspMZWrtptUc-4Uslbag3XpyMshoFb2yNhooUyHRl2Bo3snC7zyMkgToBF3zkm-TyKRuhCUk44mL89aJ3gogxV75cXGE28wMMbrzQra0unIzEgeMbmzT3saotny8ENFDfqzSHG9ZjmFnKd57cfDcVcg6b59YID3gZa9itKp3HTXLaJe5gEw85n2PdOjfXmj-i9KGXNCI890F5CZCmjBRQ

However it's not suitable for my code since I don't know how to generate this link programatically.

Like I said above, I already set my bucket to public so it's not an authorization issue and it works on my web browser.

Any idea ?


回答1:


I think the error is on the public url you're using. The URL for accessing public objects in Google cloud storage is

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

As in here: https://cloud.google.com/storage/docs/access-public-data



来源:https://stackoverflow.com/questions/53175740/google-cloud-storage-hosted-images-dont-show-in-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!