Rajni Tandon
Rajni Tandon

Reputation: 83

picasso not loading all images from firebase url in android

I am trying to load images from firebase storage through url, but all images are not being loaded, some are being loaded and some not I am using below code and Picasso library to load the images

Picasso.get().load(post.getPost_user_profile_pic_url())
                    .resize(200, 200)
                    .centerCrop()
                    .into(postUserImage);

When I tried to use Glide library as below

Glide.with(itemView.getContext()).load(post.getPost_user_profile_pic_url()).into(postUserImage);

I got the following

W

/Glide: Load failed for https://firebasestorage.googleapis.com/............ with size [120x120] class com.bumptech.glide.load.engine.GlideException: Failed to load resource There was 1 cause: java.io.FileNotFoundException(https://firebasestorage.googleapis.com/v0/b/....................) call GlideException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE

How can I rectify this problem to make sure all teh respective images are loaded from the URL?

Upvotes: 0

Views: 539

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599131

In order for Glide to load the image data from a URL, that URL needs to be publicly readable. Since you want the image data to be protected by Firebase's security rules, the URL you're using is by definitely not public.

To integrate Firebase Storage with Glide, you'll need one of Firebase's API methods to load the data to a stream, into memory, or a local file. From there you can then pass it to Glide.

I'd highly recommend using the FirebaseUI library that integrates with Glide, either directly in your code, or as an example of how to build such an integration. For the specific code that loads the data from Firebase, see this method in the code.

Upvotes: 1

Related Questions