thisbejim / Pyrebase

A simple python wrapper for the Firebase API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

adivaste opened this issue · comments

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

storage.child(folder_name).list_files()

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()

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.

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)

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