android – Load images from firebase storage without image extension-ThrowExceptions

Exception or error:

I am downloading images from firebase storage using this block of code.

val storageRef = App.fbStorage.getReferenceFromUrl(CATEGORY_ICONS_BUCKET)
                .child(patientInformation.imageName+ IMAGE_PNG)
                 GlideApp.with(context).load(storageRef)
                 .placeholder(R.drawable.ic_image_placeholder)
                 .into(infoImageView)

This works well and image is retrieved if I provide the Image format like “IMAGE_PNG” in above code.From realtime databse i only have the image names and not image extenstions. I have images which may have png or jpg or jpeg format. Is there any way that i retrieve there images by only providing the name and not providing the image extension. I tried like this

App.fbStorage.getReferenceFromUrl(CATEGORY_ICONS_BUCKET)
                    .child(patientInformation.imageName)

but it does not work.

How to solve:

You need to know the full path of an object in storage in order to work with it. There is no automatic wildcarding or guessing the name. If you don’t know the full path, and you only know a prefix of that, you can use the list API to list files with a common prefix, and work from there.

Leave a Reply

Your email address will not be published. Required fields are marked *