Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to download all the files from a folder in Firebase Storage?

$
0
0

I want to download all the files from my Firebase project's folder.

I've tried the following things:

Using NPM:

npm install -g firebase-toolsfirebase loginfirebase storage:download gs://tridosha-iks-research-project.appspot.com/audio .

Error: storage:download is not a Firebase command(I've tried storage:get too)

Using gsutil:

gsutil -r cp gs://tridosha-iks-research-project.appspot.com/audio .
Error: cp unknown hostgs://tridosha-iks-research-project.appspot.com/audio isn't a valid hostname

Using Python:

import osfrom firebase_admin import credentials, storage, initialize_app# Replace these with your actual Firebase configuration valuesfirebase_config = {"project_number": "project number","project_id": "id","storage_bucket": "bucket"  },# Initialize Firebasecred = credentials.Certificate("/home/shreyansh/Desktop/IKS/google-services.json")  # Replace with your service account key fileinitialize_app(cred, firebase_config)# Reference to your Firebase Storage bucketbucket = storage.bucket()# List the files in a specified folderfolder_path = "audio/"blobs = bucket.list_blobs(prefix=folder_path)# Download the files to a local directorylocal_directory = "/home/shreyansh/PAISA/IKS/audio"  # Replace with your local directoryfor blob in blobs:    local_file_path = os.path.join(local_directory, blob.name)    blob.download_to_filename(local_file_path)    print(f"Downloaded {blob.name} to {local_file_path}")
Error: Traceback (most recent call last):  File "/home/shreyansh/Desktop/PAISA/IKS/download.py", line 12, in <module>    cred = credentials.Certificate("/home/shreyansh/Desktop/PAISA/IKS/google-services.json")  # Replace with your service account key file  File "/home/shreyansh/.local/lib/python3.10/site-packages/firebase_admin/credentials.py", line 93, in __init__    raise ValueError('Invalid service account certificate. Certificate must contain a 'ValueError: Invalid service account certificate. Certificate must contain a "type" field set to "service_account"

.

How do I download all the files in my folder?it's okay if I can download the entire bucket too...


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>