如何从Firebase存储下载整个文件夹? [英] How to download entire folder from Firebase Storage?

查看:86
本文介绍了如何从Firebase存储下载整个文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Firebase存储中下载整个文件夹。单个文件可以通过如下获取DownloadURL来下载。但它对文件夹不起作用。

I want to download entire folder from Firebase storage. Single file can download by getting DownloadURL as follows. But it's not work for folder.

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下载整个文件夹?

How to download entire folder from Firebase?

推荐答案

Firebase存储中没有API来下载文件夹中的所有文件。您必须逐个下载文件,或创建包含所有文件的zip文件。

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.

相关:

  • How to get an array with all pictures?

这篇关于如何从Firebase存储下载整个文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆