Image Storage with Firebase
Firebase acts as a super low-friction way to add a backend to your mobile or web-app, so I put it to the test to see if I could use it to store images for a new project.
First we need to configure our Android Activity to hit our Firebase backend. Turns out this is two lines. Nice!
There is a lot of other stuff that goes on in my demo now which opens the camera, gets the user to take a photo and saves it to file on the device. Once all that is done, we should upload the file to Firebase. I’m sure there must be a better way to get it into base64 but here goes:
So we’ve stored our picture to our backend using three lines to do it. Pretty neat. What about if we want to pull it out again and display it back to the user when they open the app?
We set up an event listener that will get fired straight away with the result from the backend, as well as whenever the data changes on the server. We pull the data down and create a bitmap from it, and update our ImageView to display it, pretty awesome. We needed to use a few more lines here, but I chalk that up mostly to Java’s boilerplateyness for registering callbacks.
My impressions are that Firebase can do some pretty cool stuff pretty damn quickly. Next time I need to quickly prototype something like at a hackathon, I’ll definitely give Firebase a go. I don’t know how it would fare if your backend needs to do stuff other than act as a simple layer over your database, but for basic CRUD it seems spot-on the money.