2

I have a folder on firebase. which named 'Item'. 'Item' contains 100 images. I just want to fetch just all images Url in the list.
I have tried google documents. Google showing only for a single image. But I just need complete images URLs.

 FirebaseStorage firestore = FirebaseStorage.getInstance()
 val ref: StorageReference? = firestore.getReference("Item")


I am facing this error =
StorageException has occurred. The object​ does not exist at the  location

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Deepak Ror
  • 333
  • 1
  • 5
  • 13

2 Answers2

2

As i found in documentation this method could help public Task<ListResult> listAll ()

First you need to get needed reference of the folder in your case it is item/

StorageReference mImageStorage = FirebaseStorage.getInstance().getReference().child("items/");

And then with help of listAll() inflate the list of files in it

Here is the description https://firebase.google.com/docs/reference/android/com/google/firebase/storage/StorageReference.html#listAll()

Bo Z
  • 2,359
  • 1
  • 13
  • 31
  • firestore = FirebaseStorage.getInstance() val ref: StorageReference? = firestore.getReference("Item/") ref?.listAll()?.addOnSuccessListener { val item = it.items list.layoutManager = LinearLayoutManager(activity) list.adapter = Adapter(activity, item) } – Deepak Ror Aug 09 '19 at 04:25
  • It's working, thanks. I have done. This is the right solution. – Deepak Ror Aug 09 '19 at 04:27
1

You're calling firestore.getReference("Item"), which gives you a StorageReference to that folder. The Android, iOS and JavaScript SDKs of Firebase recently added a method to list the files in a folder to StorageReference.

So you need to loop over the ListResult and call getDownloadUrl to get the download URL for each file. Keep min mind that getDownloadUrl is asynchronous, so it returns a task. Get the actual download URL as shown here: How to get the download url from Firebase Storage?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807