【发布时间】:2017-05-18 14:20:27
【问题描述】:
我想从 Firebase 存储中下载整个文件夹。我可以使用DownloadURL 下载单个文件,如下所示,但它不适用于文件夹。
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;
}
});
如何从 Firebase 下载整个文件夹?
【问题讨论】:
-
关于您期望的预期行为的问题:所有文件的数组、包含所有文件的压缩文件夹,还是其他?
-
@MikeMcDonald 我想下载一个包含所有文件的压缩文件夹。
-
这是一个优雅的解决方案,可以解决您的所有问题,在客户端一次下载所有文件作为单个 .zip 文件:stackoverflow.com/a/66732338/8138591(2021 年 3 月 21 日)
标签: javascript firebase firebase-storage