thisbejim / Pyrebase

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

Download Not Working #443

Open snehitvaddi opened 1 year ago

snehitvaddi commented 1 year ago
firebase = pyrebase.initialize_app(config)
storage = firebase.storage()
with open("filenames.txt", "r") as f:
    for i in f.readlines():
        try:
            storage.child(i).download("downloads/")

The cell is getting executed but nothing is getting downloaded

AsifArmanRahman commented 1 year ago

You're doing it wrong. Check documentation here

snehitvaddi commented 1 year ago

Okay, Thank you In that case, will below code shouls work?

storage = firebaseApp.storage()
storage.child(<firebase_file_path.jpg>).download("downloads/")

I tried this, but didn't work. So, is userToken mandatory for download? If yes, where can I get the uer token from?

AsifArmanRahman commented 1 year ago
  1. Token could be mandatory based on your security rules for storage.

  2. The below code should work, as you can see, I'm defining a filename with extension for that file in the download method.

    storage = firebaseApp.storage()
    storage.child("firebase_file_path/file.jpg").download("downloads/download.jpg")


Note: the downloads folder might not be created on your local machine automatically if it doesn't exist already which should throw an error. Also if it fails with pyrebase, please try the firebase-rest-api library.