Can't service images directly from Firebase Storage

1,976 views
Skip to first unread message

Cuong Tran

unread,
May 18, 2016, 11:05:56 PM5/18/16
to Firebase Google Group
The new Storage service is great but it seems that my app needs to call Firebase API for each image before it can be served to the client.  It doesn't seem efficient, especially for mobile clients which Firebase specifically is designed for.

Am I missing a something?

Thanks.

Mike Mcdonald

unread,
May 18, 2016, 11:41:58 PM5/18/16
to Firebase Google Group
Hi Cuong,

Thanks for the feedback! You can download files from Firebase Storage in memory or to a file on the device. If you download the file on the device, you don't have to re-download the file each time--it'll be stored on your device!

You can also cache the download URLs (using your desired system URL cache), so even if you perform multiple requests, it'll get the image from the local cache. This wasn't included directly in the client, since we didn't want to cache a ton of user downloaded content without making it highly configurable, as this could easily be 10's to 100's of MB.

In the future, we're hoping to provide a configurable URL cache built in (you would specify the max size) and let you keep references to a file cached. We'd love your feedback on this :)

Thanks,
--Mike

Mario Giambanco

unread,
May 19, 2016, 10:11:53 AM5/19/16
to Firebase Google Group
"In the future, we're hoping to provide a configurable URL cache built in (you would specify the max size) and let you keep references to a file cached. We'd love your feedback on this :)"

Are you implying a sort of competitor to cloudinary.com ? Where requested images could be transformed on demand or am I reading to much into this.

Cuong Tran

unread,
May 19, 2016, 5:36:11 PM5/19/16
to Firebase Google Group
How is this applied to web client? I want to display a list of images and it seems I will need to loop through each one and call firebase to get a public url to use in the html.

Mike Mcdonald

unread,
May 19, 2016, 6:37:04 PM5/19/16
to Firebase Google Group
Mario,

Adding an image pipeline (ala cloudinary, thumbor, imgix, etc.) would be an interesting addition to the product, but no, that's not what I was referring to. I was just saying that it would be possible to

Cuong,

Typically, the flow for this is the following:
  • Upload the file to Firebase Storage
  • Observe for a successful upload
  • Successful upload returns a public download URL
  • Store this download URL somewhere that a client can get it (we recommend the Firebase Realtime Database)
  • Subscribe to changes on that Database to get said URL (without having to access data again in Storage)
  • Download the image as necessary
It's actually super quick and efficient to build your app this way. Since I've got some sample code already open (Swift ~= JS, so hopefully it's understandable) for this:

storageRef.putData(NSData()).observeStatus(.Success) { (snapshot) in

   databaseRef.setValue(snapshot.metadata?.downloadURL())

}

databaseRef
.
observeEventType(.ChildAdded, withBlock: { (snapshot) in

   let url = snapshot.value

   // download URL

})


Thanks,
--Mike

Cuong Tran

unread,
May 20, 2016, 12:04:23 AM5/20/16
to Firebase Google Group
Thanks for the example, that helped to clarify what I was missing (the download url is accessible after an upload).

Benjamin Wulfe

unread,
May 24, 2016, 1:14:54 PM5/24/16
to Firebase Google Group
Just to clarify.  Once you upload a file to Firebase Storage, you can choose how to share and download that file.
You can either:

a) Share a public unguessable Url.  Anyone can use this Url to download the file.  This Url is available to you upon successful upload to the cloud
b) You can call the Firebase Storage API to download a StorageReference (FIRStorageRef).  You must have logged in via Firebase Auth previously and must pass security rules to download the file.  

The advantage of a) is that you can use a wide variety of libraries that do caching of downloads since you do not need authentication information passed to the cloud.
b) is preferable if you want to ensure all access to the file is run through security rules.

Doug Thompson

unread,
Jun 16, 2016, 9:53:01 AM6/16/16
to Firebase Google Group
Benjamin -

Is it possible to run Firebase storage concurrently with Firebase legacy?

Converting an app from Firebase 2.0 will be a large task but can we take advantage of Firebase Storage before that conversion is complete?

Jacob Wenger

unread,
Jun 16, 2016, 11:57:24 AM6/16/16
to fireba...@googlegroups.com
Hey Doug,

Firebase Storage is only available via the 3.x.x SDK. Running the 2.x.x and 3.x.x SDKs side-by-side is not a supported feature.

Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/2687eb77-3e74-4352-92f8-0b6ef45bb351%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Doug Thompson

unread,
Jun 16, 2016, 11:59:31 AM6/16/16
to Firebase Google Group
What I thought. :)

Time to take the big leap! 

Jacob Wenger

unread,
Jun 16, 2016, 12:42:43 PM6/16/16
to fireba...@googlegroups.com
Good luck! You know where to find us if you have questions or run into issues :)

Jacob

Reply all
Reply to author
Forward
0 new messages