Flutterfire: [firebase_storage] Include List API.

Created on 3 Sep 2019  Â·  31Comments  Â·  Source: FirebaseExtended/flutterfire

Is your feature request related to a problem? Please describe.
As described in the Firebase docs, the List API allows the client to list all files and subdirectories inside a given folder. This is very helpful for when the contents of a directory are not known in advance, and avoids temporary workarounds (such as a Cloud Function that populates an index in Cloud Firestore)

Describe the solution you'd like
A list and listAll method for StorageReference that provides access to the List APIs.

Additional context
Again, this removes the need for complicated and buggy workarounds, as well as minimizing the connection between Firebase services -- by introducing users to Cloud Function and Cloud Firestore, chances are something will go wrong as opposed to simply using Cloud Storage.

crowd storage enhancement

Most helpful comment

God help us all.

So we need to keep track of our own files?

All 31 comments

This seems like a good idea! I don't have a timeline on implementation but PRs would be most welcome.

I am also surprised I cannot list all files in the bucket. Is there any way I can do this with firebase_storage: ^3.0.6?

I use metadata.

Say you want to list all the articles in a folder. You can have a file named, say, articles.txt inside with metadata: issues = ["article_1.pdf", "article_2.pdf"]. Since metadata can only have String keys and values, you can either encode the list as json or, if it's just a list, use Iterable.join and String.split: metadata = {"issues": "article_1.pdf, article_2.pdf"}

Any news on this? Having to track all the filenames my users upload to know them in advance is a huge pain. If I could just list the filenames in a bucket or folder, that would be extremely helpful

Well it seems that #232 is working on this. It's almost done, just some minor cleanup needed. Fair warning it doesn't lazy load -- all filenames are loaded in memory at once. Only a problem if you have literally thousands of files in the same folder.

@Levi-Lesches

Only a problem if you have literally thousands of files in the same folder.

That would probably be the case most of the time with user-generated content.

Yep, totally agree, at least I'm lucky enough to not have that particular issue. According to the PR:

I will try to implement also the "pagination" feature, but for the moment I have some crazy days so maybe next week.

@Levi-Lesches

Only a problem if you have literally thousands of files in the same folder.

That would probably be the case most of the time with user-generated content.

Won't be an issue for me thankfully. Can't imagine having more than 15 files in the same folder. Thanks for the responses

How is this not possible yet? I don't understand the point of folders if I cannot simply get the files inside the folder. I might just throw the images into firestore documents if this can't be done

How is this not possible yet? I don't understand the point of folders if I cannot simply get the files inside the folder. I might just throw the images into firestore documents if this can't be done

You can use this until the PR is merged:

dependencies:
  firebase_storage:
    git:
      url: git://github.com/danysz/flutterfire.git
      ref: master
      path: packages/firebase_storage

@collinjackson and @kroikie, @danysz has made a PR over at #232 that solves this issue any chance it can be merged?

This seems like a fairly _basic_ functionality, critical to most applications using Storage. Is there anything holding up the merge?

It's like 8 months since I made it. They just made me to stop publishing and contributing to the "flutter/firebase" community. Sorry

No worries, I was aiming the question more at the Google people in charge of the repository.
From what I can tell after testing it on Android, it works fine, so I'd love to see it in the official package.

I am sure is working fine, I have it in apps which are published both on
Android and iOS for production and with users.

DANIEL SZASZ
CTO & Co-Founder

From: Zalán Meggyesi notifications@github.com notifications@github.com
Reply: FirebaseExtended/flutterfire
reply@reply.github.com
reply@reply.github.com
Date: 15 May 2020 at 16:54:53
To: FirebaseExtended/flutterfire flutterfire@noreply.github.com
flutterfire@noreply.github.com
Cc: Daniel Szasz danysz@gmail.com danysz@gmail.com, Mention
mention@noreply.github.com mention@noreply.github.com
Subject: Re: [FirebaseExtended/flutterfire] [firebase_storage] Include
List API. (#83)

No worries, I was aiming the question more at the Google people in charge
of the repository.
From what I can tell after testing it on Android, it works fine, so I'd
love to see it in the official package.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/FirebaseExtended/flutterfire/issues/83#issuecomment-629249261,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAMXGQDUJNZCFAOXNA3QIALRRVCSZANCNFSM4ITKB3HQ
.

OK, Google, I need this now. Please don't make me resort to JavaScript.

@collinjackson What's holding up this PR? People need this functionality, and there's a solution for it - what's keeping Google from merging this?

Can someone please review the PR? We need this functionality.

God help us all.

So we need to keep track of our own files?

What I had is a .txt file in each directory with the names of all the files inside, and used cloud functions to keep it up-to-date.

Also, courtesy of @Hannnes1 above:

You can use this until the PR is merged:

dependencies:
  firebase_storage:
    git:
      url: git://github.com/danysz/flutterfire.git
      ref: master
      path: packages/firebase_storage

@kroikie do you think you could _champion_ this PR for integration? People are looking for this functionality, and having to resort to all sorts of workarounds to get it.

God help us all.

So we need to keep track of our own files?

Yup. One implementation I wrote cloud functions which update firestore documents to keep track of all the file names. In another, I just wrote the small images as base64 to firestore documents directly and avoided firebase storage entirely.

I have no idea how they intend one device to upload a photo, and another to download it, if you need the exact filename. You need another system to keep track of the file names, or you need to name the files in a very precise way where you can know the filename based on what it might be associated with.

Keep in mind this feature _does_ exist in Firebase, just hasn't been ported over to Flutter yet. And it's happening soon (although it did take a VERY long time). They're completely reworking most if not all of the Firebase plugins so they're not gonna use that specific PR but it's in the works.

@Levi-Lesches Do you have any infos regarding an ETA?

The original PR was https://github.com/FirebaseExtended/flutterfire/pull/232, but it got moved (with a different implementation) under the new reworks to https://github.com/invertase/flutterfire/pull/53, but it's marked as a work in progress. According to a medium article:

To make sure that we’re working on the highest impact plugins for Flutter developers, our next round will likely be Crashlytics, Functions, Messaging, and Storage.

So they're probably picking up the pace now.

Any Updates? It's about a year now.

Any Updates? It's about a year now.

They made good progress recently.
Check out this branch https://github.com/invertase/flutterfire/tree/%40ehesp/storage-wip
It has a working listAll method. Let's hope it will be merged soon.

https://github.com/invertase/flutterfire/pull/53 has merged! Only a matter of time until it gets merged to this repo as well.

@Levi-Lesches Thank you so much for pushing this!

Hey all, as @Levi-Lesches mentioned above, our rework PR is up at #3612 and is now going through dev release cycles. A firebase_storage dev release is now available (5.0.0-dev.1) with all the changes in that PR including the listing API - please could you try it out and provide feedback on the PR :)

Thanks

Was this page helpful?
0 / 5 - 0 ratings