how to load an image in imageview with the help of glide from Cloud Storage with url(gs://xxxx)

Viewed 30

I am trying to load an image with the help of glide library but it cannot load the image when i use the (gs://xxx) firebase storage reference

@Override
public void onBindViewHolder(@NonNull viewHolder holder, int position) {

    Data_demo dataDemo = ndata.get(position);
    holder.name.setText(dataDemo.getName());
    holder.desc.setText(dataDemo.getDesc());
    FirebaseStorage storage = FirebaseStorage.getInstance();
    StorageReference storageRef = storage.getReference(dataDemo.getImage());

    Log.d(TAG, "onBindViewHolder: "+dataDemo.getImage());
//   
    Glide.with(context).load(storageRef).into(holder.imageView);

}

datademo is the model class in that i had declare 3 variable in with datatype String name, desc and image dataDemo.getImage() it consist of (gs://xxxxx) url

1 Answers

By default Glide has no knowledge of URLs starting with gs://, as that protocol is specific to Google Cloud Storage and glide only knows how to handle http:///https://.

You have two options:

  • Load the data from the URL via the Firebase SDK, and show that in the ImageView.
  • Use FirebaseUI or a similar library, which extends Glide to be able to load gs:// URLs.
Related