0

I want to get this full URL:

https://firebasestorage.googleapis.com/v0/b/myapppakage-f7aa6.appspot.com/o/flat%2044%2F1image_1.jpg?alt=media&token=8907b845-a1f5-4bdb-8e76-215fc6fc5129

I want to show images in android slider using full URL.

I got this URL gs://myapppakage-f7aa6.appspot.com/flat 44/image_1.jpg
But I can`t access images to show in my slider.

My Kotlin Code

private fun retriveImagesFromStorage(flatName: String) {

 val firebaseStorage = FirebaseStorage.getInstance().reference
 val storageRef: StorageReference = firebaseStorage.child(flatName)

 storageRef.listAll().addOnSuccessListener { result ->
            // go through all the files/folders
            imageList.clear()
            result.items.forEach { storageRef ->
                // get the download URL for each of the file
               storageRef.downloadUrl.addOnSuccessListener { uri ->
                   imageList.add(uri.path.toString())
               }
            }
        }
        .addOnFailureListener {
            Toast.makeText(this, "Unable to fetch items!", Toast.LENGTH_SHORT).show()
            it.printStackTrace()
        }

}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Does this answer your question? [Firebase how to get Image Url from firebase storage?](https://stackoverflow.com/questions/40177250/firebase-how-to-get-image-url-from-firebase-storage) – Antonio Apr 17 '21 at 16:33
  • I'm not sure I understand. Can you show where in this code you that that non-functioning URL? – Frank van Puffelen Apr 17 '21 at 17:05
  • No. because i want to fetch URL and apply to show images. NOT uploaded time URL which are return downloadURL -- Antonio – Asad Zaman Apr 17 '21 at 17:35
  • I think this [answer](https://stackoverflow.com/questions/53299915/how-to-get-offline-uploaded-file-download-url-in-firebase/53300660#53300660) might help, right? – Alex Mamo Apr 18 '21 at 08:21

1 Answers1

0

Check this link: https://firebase.google.com/docs/storage/android/download-files#download_data_via_url

val storageRef = Firebase.storage.reference
storageRef.child("folder/subfolder/picture.png").downloadUrl
    .addOnSuccessListener { url ->
        // do whatever with your url
    }
    .addOnFailureListener { exception ->
        Log.e(TAG, "Exception: ${exception.message}")
    }
Antonio
  • 240
  • 3
  • 15
  • I want the URL(which i defined) just for display images. **NOT uploaded time URL which are return downloadURL** – Asad Zaman Apr 17 '21 at 17:43