Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_storage] Include List API. #83

Closed
Levi-Lesches opened this issue Sep 3, 2019 · 31 comments
Closed

[firebase_storage] Include List API. #83

Levi-Lesches opened this issue Sep 3, 2019 · 31 comments
Assignees
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: storage type: enhancement New feature or request

Comments

@Levi-Lesches
Copy link
Contributor

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.

@Levi-Lesches Levi-Lesches added the type: enhancement New feature or request label Sep 3, 2019
@collinjackson
Copy link
Contributor

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

@SheriefAlaa
Copy link

SheriefAlaa commented Sep 18, 2019

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?

@Levi-Lesches
Copy link
Contributor Author

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"}

@MilesAdamson
Copy link

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

@Levi-Lesches
Copy link
Contributor Author

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.

@creativecreatorormaybenot
Copy link
Contributor

@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.

@Levi-Lesches
Copy link
Contributor Author

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.

@MilesAdamson
Copy link

@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

@MilesAdamson
Copy link

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

@Hannnes1
Copy link

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

@Levi-Lesches
Copy link
Contributor Author

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

@zmeggyesi
Copy link

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

@danysz
Copy link

danysz commented May 15, 2020

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

@zmeggyesi
Copy link

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.

@danysz
Copy link

danysz commented May 15, 2020 via email

@awhitford
Copy link
Contributor

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

@zmeggyesi
Copy link

@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?

@kroikie kroikie assigned kroikie and unassigned collinjackson Jul 2, 2020
@raphtlw
Copy link

raphtlw commented Jul 8, 2020

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

@bretmh
Copy link

bretmh commented Jul 13, 2020

God help us all.

So we need to keep track of our own files?

@Levi-Lesches
Copy link
Contributor Author

Levi-Lesches commented Jul 14, 2020

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

@zmeggyesi
Copy link

@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.

@MilesAdamson
Copy link

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.

@Levi-Lesches
Copy link
Contributor Author

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.

@pumuckelo
Copy link

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

@Levi-Lesches
Copy link
Contributor Author

The original PR was #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.

@being-yash-t
Copy link

Any Updates? It's about a year now.

@timekone
Copy link

timekone commented Sep 18, 2020

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.

@Levi-Lesches
Copy link
Contributor Author

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
Copy link
Contributor Author

Follow #3612 for progress

@zmeggyesi
Copy link

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

@Salakar
Copy link
Member

Salakar commented Sep 22, 2020

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

@Salakar Salakar closed this as completed Sep 22, 2020
@firebase firebase locked and limited conversation to collaborators Oct 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: storage type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests