thisbejim / Pyrebase

A simple python wrapper for the Firebase API.
2.05k stars 525 forks source link

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

Open adivaste opened 2 years ago

adivaste commented 2 years ago

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

hereisamara commented 2 years ago

storage.child(folder_name).list_files()

adivaste commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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