How to download entire folder from Firebase Storage?
Solution 1
There is no API in Firebase Storage to download all files in a folder. You will have to download the files one by one, or create a zip file that contains all the files.
As Lahiru's answer shows it can be accomplished with gsutils
, but that's a server-side operation - not something you'd run in your client-side application.
Related:
Solution 2
You can use gsutil to download the whole storage bucket
gsutil -m cp -R gs://<bucket_name> .
Solution 3
Command gustil for Windows !!!
gsutil cp -r gs://<bucket_name>.appspot.com/OBJECT_NAME "D:\path"
Use Cloud tools for PowerShell
REF for install windows >> https://cloud.google.com/storage/docs/gsutil_install
isuru
By Day - Like to find new coding standards and best practices
Updated on July 09, 2022Comments
-
isuru almost 2 years
I want to download an entire folder from Firebase storage. I can download single files using
DownloadURL
as follows, but it does not work for folders.var storageRef = firebase.storage().ref(); // Create a reference to the file we want to download var starsRef = storageRef.child(path); // Get the download URL starsRef.getDownloadURL().then(function(url) { // Insert url into an <img> tag to "download" ImageUrl = url; console.log(ImageUrl); }).catch(function(error) { switch (error.code) { case 'storage/object_not_found': // File doesn't exist break; case 'storage/unauthorized': // User doesn't have permission to access the object break; case 'storage/canceled': // User canceled the upload break; case 'storage/unknown': // Unknown error occurred, inspect the server response break; } });
How to download entire folder from Firebase?
-
isuru over 7 yearsI cannot find the way to get all the files and create a zip file from above related links. Please give me some tips to find a way to create a zip file that contains all the files. Thanks for your response.
-
ismaestro over 5 yearseasiest solution!
-
HartleySan over 4 yearsThis worked well. Installing
gsutil
was the most time-consuming part. -
Lorence Cramwinckel about 4 yearsDon't forget to enter the destination URL after the gsutil command like so:
gsutil cp -r gs://<bucket_name>.appspot.com Downloads
The destination URL must name a directory, bucket, or bucket subdirectory. -
Xeaza about 4 yearsOne thing that tripped me up for a bit was I forgot to add the
.
at the end in the answer above. That.
is important :) -
Ritwik about 4 yearsrefer to this for installing gsutil
-
Swetabja Hazra over 3 yearsThanks, this saved my life. I accidentally deleted files which were only there in my firebase storage.
-
151291 over 3 yearsBut, this is system-level installation right? how to archive it via Node APIs?
-
Trake Vital over 3 yearsBtw in windows you should run the shell in administrator to not get
Access Denied
-
Soorya over 3 yearsAppending folder name after the bucket url also works (if you want to download only one particular folder).
-
MorenoMdz about 3 yearsIs it possible to run that from the backend Admin SDK?
-
RumbleFish about 2 yearsgsutil is also available for Mac, terminal command is same as above (change dest. path!)... cloud.google.com/storage/docs/gsutil_install#mac