0

I am using Glide 4.9.0 with firestore in Android Kotlin.

Images are getting save in firestore with path. But when i try to load path reference to Glide, it shows nothing but set imageview blank .

Activity Code:

FirestoreUtil.getCurrentStudent { student ->    

                    Glide.with(this)
                        .load(student?.profilePicturePath.toString())
                        .diskCacheStrategy(DiskCacheStrategy.DATA)
                        .transform(CircleCrop())
                        .into(stdProfile)
                }

Firestore Path:

gs://xxxx-xxxxx.appspot.com/xybyiF9LkxXorrrEgu3PKpy6b6t1/profilePictures/94af9ef2-12f6-3657-8367-2e505bc37cc2

url from firestore database and storage: enter image description here

enter image description here

ALi
  • 430
  • 7
  • 19
  • Please post the log of path and Firebase storage Location – Ashish Sep 07 '19 at 08:34
  • @Ashish i have updated question with Firestore Path – ALi Sep 07 '19 at 08:46
  • ali the path your provided is not perfect. Cause there is no Extension to your file. Please check your path. It needs to be something like this `gs://**.appspot.com/images/6g74sRdiPh5BVApVtOFM.jpg` – Ashish Sep 07 '19 at 09:00
  • Thank you @Ashish, So issue is in uploading image. My code for uploading image is – ALi Sep 07 '19 at 09:03
  • fun uploadProfilePhoto(imageBytes: ByteArray, onSuccess: (imagePath: String) -> Unit){ val ref = currentStudentRef.child("profilePictures/${UUID.nameUUIDFromBytes(imageBytes)}") ref.putBytes(imageBytes).addOnSuccessListener { onSuccess(ref.path) } } – ALi Sep 07 '19 at 09:04
  • can you guide that how i can make extension from this function? – ALi Sep 07 '19 at 09:04
  • 1
    Please shouw us how is your url stored in the database as a screenshot please. Please also responde with @AlexMamo – Alex Mamo Sep 07 '19 at 09:07
  • @ALi Issue isn't with uploading image i think issue is in your Database storing. – Ashish Sep 07 '19 at 09:11
  • @AlexMamo updated question with screenshots – ALi Sep 07 '19 at 09:25
  • @ALi you didn't convert imagebyte. Please check the [post](https://firebase.google.com/docs/storage/android/upload-files?authuser=1#upload_from_data_in_memory). You need to follow those steps and convert into byteArray – Ashish Sep 07 '19 at 09:27
  • 1
    That's not a proper url. Check the way you are uploading that url. – Alex Mamo Sep 07 '19 at 09:40
  • @AlexMamo now my url is gs://xxxx-xxxx.appspot.com/xybyiF9LkxXorrrEgu3PKpy6b6t1/profilePictures/me.jpg but still its blank – ALi Sep 07 '19 at 11:28
  • @ALi Can you open that url in browser? – Alex Mamo Sep 07 '19 at 11:29
  • it opens in browser when i add "https://firebasestorage.googleapis.com/" in start – ALi Sep 07 '19 at 11:33

2 Answers2

0

Actually issue was not the URL, my url is correct.

This post helped me to show gs url in Glide using Firestore UI.

Thanks

ALi
  • 430
  • 7
  • 19
  • Did you store the actual images in Storage and store the url in Firestore and then show them with FirestoreUI? – ikmazameti Apr 27 '21 at 23:48
0

Additional to ALis Link I had to add Request options to the GlideApp for it to work with the following versions:

implementation 'com.firebaseui:firebase-ui-storage:6.1.0'
implementation "com.github.bumptech.glide:glide:4.9.0"
kapt 'com.github.bumptech.glide:compiler:4.9.0'

Taken from: How to load Image into ImageView from Url using Glide v4.0.0RC1

val options : RequestOptions = RequestOptions()
    .centerInside()
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.error)
GlideApp.with(this /* context */)
    .load(imageRef)
    .apply(options)
    .into(imageView)