Omortis
Omortis

Reputation: 1530

Flutter load Image.network() from google cloud platform

I have uploaded some assets to my project in Google Cloud Storage. GCS provides URLs of this type for uploaded files:

https://storage.cloud.google.com/my-app.appspot.com/items/Peach.jpg

This URL does not work as an argument to Image.network() in flutter, probably because it redirects to a long, not really human readable URL if opened in a browser.

Is there a way to use the gs:// link provided by GCS in flutter? Or do I need to use the cloud_storage plugin to download the image within the flutter app and save it as a temporary local file to use it?

Please note that most images live within the flutter app, but there is some stuff I'd like to change on the fly without having to re-release through the relevant stores.

Upvotes: 2

Views: 2025

Answers (1)

Tiago Santos
Tiago Santos

Reputation: 766

Create a public bucket and then instead of https://storage.cloud.google.com use the public URL https://storage.googleapis.com/.

If you need to keep the bucket private you can use the big URL you're redirected to.

Upvotes: 2

Related Questions