I wanted to create an image slider to show images from the Firestore
. I searched online a lot but didn't find anything to get started. There are a few videos online but they are for Java
, but I want for Kotlin
. I have made a set-up to upload an image but I can only upload one image per product. How can I upload multiple images per product and show display them too? Thank you.
Asked
Active
Viewed 274 times
0

Codist
- 737
- 8
- 23
-
Have you solved the issue? What have you tried so far in code? – Alex Mamo Jun 28 '21 at 15:37
1 Answers
0
Firestore does not support native images, it is a Document based database with a JSON like structure. You could convert images to Base64 strings, but you would have to ensure they are compressed as Firestore documents are restricted to 1MB each.
Once you download the firestore document, you convert it back from base64 to an image asset that you can insert within your app like you would a standard asset/image
Resources:
- Compress image: https://stackoverflow.com/a/60371129/2301161
- Convert to Base64: https://stackoverflow.com/a/4830846/2301161
- Convert to Image: https://stackoverflow.com/a/58955588/2301161
- Kotlin Image Slider: https://morioh.com/p/f79555321fff

DIGI Byte
- 4,225
- 1
- 12
- 20
-
Isn't it possible to use the image stored in the Storage in the Firestore? – Codist Jun 26 '21 at 04:28
-
Storage is a Dropbox like file sharing, while Firestore is like a Word Document collection - they are not compatible. you can generate downloadURL's from storage files and save them in Firestore but that is not what your question asked. – DIGI Byte Jun 26 '21 at 04:31
-
Sorry about that, what I need is that I have a collection called 'orders' in my `Firestore` database which has a field called 'image' which contains the URL of the image stored in the Firebase Storage. I want to display these images in the Image Slider. – Codist Jun 26 '21 at 04:51
-
Then all you need to do is insert the image URL into the image source, when you save the image URL, make sure it's a Download URL that has the access token attached. And depending on your Image Slide: Glide: `Glide.with(context).load(uri).into(imageView)` – DIGI Byte Jun 26 '21 at 05:45
-
https://egemenhamutcu.medium.com/displaying-images-from-firebase-storage-using-glide-for-kotlin-projects-3e4950f6c103 – DIGI Byte Jun 26 '21 at 05:45