DEV Community


Posted on

How to use square‘s picasso library with firebase storage

Recently i was migrating an app’s backend from parse to firebase. The move to firebase’s real-time database was a breeze with minor re-factoring. I hit a block when i wanted to load images stored in firebase storage into an android Imageview. The existing code had used the excellent picasso from square for image caching and the likes. Earlier i had stored the images as blobs inside my parse database. Firebase storage has image location coming in this format. gs://

One option was to load the image location (http based)inside a field in the real time database and access it using picasso. This particular app had lot of images and i didn’t want to go that route. Reading through picasso’s documentation i came across picasso’s request handler.

Actually the implementation was easy to code and simple enough. Below is the gist

The changes while actual loading is that you need to create a picasso instance using the builder while passing our custom request handler. Eg:

picassoInstance= new Picasso.Builder(this.activityContext.getApplicationContext())
.addRequestHandler(new FireBaseRequestHandler())

Then to load image into the imageview


Top comments (0)