1

Hi guys I am making a wallpaper android app.I have stored all my images in firebase storage. Now I have a recyclerview and want to retrieve each of the images into that recyclerView by getting list url of the folders.Is there any way to do that without using the database.I have pasted the json file into my app.

mohamad.zamani
  • 105
  • 2
  • 14
  • what do you mean by without database? – Tara Nov 28 '17 at 07:58
  • well, you can download all images from firebase storage at once and store into external/internal storages and retrieve from them later. – Muhammad Saad Nov 28 '17 at 07:59
  • I uploaded the images because I want to retrieve it from the internet so I don't want to download it.without database means I want to get the image list URL directly from storage in firebase. – mohamed rimshadpcs Nov 28 '17 at 08:07

2 Answers2

3

In order to download a image/images from Firebase Storage, you first need to have the corresponding url/urls. To download an image, it requires four steps:

  1. Upload the image to Firebase Storage.
  2. Save the corresponding URL to Cloud Firestore/Firebase Database database while uploading.
  3. Attach a listener on the folder you have saved the image.
  4. Display the image.

So there is no way in which you can download an image without knowing the URL. You cannot get the image list URL directly from Firebase Storage.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • I disagree with steps 2 and 3. Yes, you need to have corresponding url/urls, but not necessary inside Firebase Database. You can save it out of box (firebase), for example inside JSON file (but you need to provide this file to all of your clients). Then all you need is deserialise this JSON and get corresponding image url, and show it with e.g. Glide/Fresco. – Tomas Ivan Nov 28 '17 at 11:58
  • @TomasIvan As I mentiones in my answer, i said that you cannot download an image without knowing the corresponding url. But I did not say anywhere in my answer that you can do it only with Firebase. If you store the images in Firebase Storage, it's a common practice to save the coresponding urls in Firebase database. That's why i mentioned this to have the process as simple as possible. And let's be honest, why to store the urls in a JSON and deserialise it after that when using Firebase is so easy? – Alex Mamo Nov 28 '17 at 13:26
0

First at all you need to have corresponding URLs of your image data stored in Firebase, as mention Alex Mamo. You can build list of this urls during upload or copy them from Firebase Console. Storage API doesn't provide any way how to retreive list of stored files.

Also, you can find Download URL in Image detail/properties. Then you can insert urls into JSON file (or another file, service, firebase storage, whatever) and load them in app.

But be careful, this is not a good idea because Firebase Storage (especially spark plan has limits) allow you download 1GB/day and only 50k/day (download/upload) operations. That will be wasted pretty soon if you don't optimise your data and number of reading operations.

Tip: When you select pay as you go most expensive is GB Downloaded, so you absolutely should store at least 1 thumbnail which will be shown in your recycler view.

enter image description here

Tomas Ivan
  • 2,212
  • 2
  • 21
  • 34
  • "You can find Download URL in Image detail/properties.". It's true but let's say you have 1000 images, how do you get the corresponding urls? You get them manually from Firebase Console? I strongly recommend not do something like this. And why do you guide him not to use Firebase? It's up to the OP to decide which choice is better for him. – Alex Mamo Nov 28 '17 at 13:27
  • Totally agree with you, it would be insane to get them this way. I only show this is possible. But if I know is possible to create another "app" just for upload, which will collect all image urls for you. And I don't guide him not to use Firebase, I'm firebase user. But some users may have a problem with price policy. – Tomas Ivan Nov 28 '17 at 13:44
  • And yes, use storage+database is way more easier than this approach. – Tomas Ivan Nov 28 '17 at 13:45