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

How can I get list of all the files in storage ? #414

Open
adivaste opened this issue Apr 4, 2022 · 5 comments
Open

How can I get list of all the files in storage ? #414

adivaste opened this issue Apr 4, 2022 · 5 comments

Comments

@adivaste
Copy link

adivaste commented Apr 4, 2022

I wanna extract all the files in the particular firebase folder, how can I do ?

@hereisamara
Copy link

storage.child(folder_name).list_files()

@adivaste
Copy link
Author

adivaste commented Apr 14, 2022

Still Unable to extract files from particular folder, giving the same Object as output for both of the lines...
( Listing whole files from Firebase Storage )

firebaseFiles = storage.list_files()
firebaseFiles = storage.child("chartjs").list_files()

@hereisamara
Copy link

Please add service account json file as shown in picture.
Then only the method will work,

files = storage.child("pictures").list_files()
for f in files:
    print(f)

image

p.s. After I have searched for a while, I found out the method used in pyrebase is deprecated, so you can only list all the files in the storage, not files from just one folder. Even if you use storage.child(folder).list_files(), it will still show all the files in the whole storage.

@hereisamara
Copy link

If you want files only from a particular folder, you can use this, where the prefix is your folder name followed by a /.

files = storage.bucket.list_blobs(prefix="folder_name/")
for f in files:
    print(f)

@adivaste
Copy link
Author

adivaste commented Apr 16, 2022

Yeah, I was doing it with a similar kind of method, but in this way, it might take a little more time.
btw thanks for it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants