I would like to list all the files and folders in a specific directory inside firebase cloud storage. I have tried using files = storage.list_files()
from other stack overflow answers. This lists all the files and folders. I have tried using files = storage.list_files(prefix='images/')
but it does not work.
I am using pyrebase4 to initialize the app and I have even provided serviceAccount but it did not work.
bucket = storage.bucket()
bucket.list_blobs(prefix="files/")
Please respond with the libraries you are importing, the syntax of initializing firebase app and finally the code to fetch list of all files from a specific directory in firebase cloud storage.
If the above is not possible, would it be very resource demanding (time & cost) to do a storage.list_files().includes(file_to_be_searched)
every time? for let’s say, 10k total files.
2
Answers
For posterity, the list_files() will always list all the files because it is deprecated. https://github.com/thisbejim/Pyrebase/issues/414#issuecomment-1100009426
This code should work to list all the files and folders in a specific directory (copying from the link mentioned above).
The example provided is using the firebase admin sdk for python.
Given that you said you are using pyrebase you’d have to use pyrebase
Yes it will to both.