Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
117
rated 0 times [  121] [ 4]  / answers: 1 / hits: 34235  / 8 Years ago, wed, january 4, 2017, 12:00:00

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?


More From » firebase

 Answers
15

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:



[#59465] Monday, January 2, 2017, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sabrina

Total Points: 92
Total Questions: 92
Total Answers: 85

Location: Palestine
Member since Thu, Feb 2, 2023
1 Year ago
;