Flutter-从Firebase存储中获取所有图像 [英] Flutter - Get all images from firebase storage

查看:112
本文介绍了Flutter-从Firebase存储中获取所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将图像手动上传到Web中的Firebase存储控制台.我想将所有图像下载到我的Flutter Android应用程序中.但是使用getDownloadUrl()方法一次只能获取一张图像.

I am manually upload my images to firebase storage console in web. I want to download all images to my flutter android app. But it is getting only one image at a time with getDownloadUrl() method.

在android中,listAll()方法列出此StorageReference下的所有项目(文件)和前缀(文件夹).

In android, listAll() method List all items (files) and prefixes (folders) under this StorageReference.

像这样,有人在扑朔迷离地建议我.

Like this, anyone suggest me in flutter.

我看到了堆栈溢出问题的答案,例如没有可立即下载所有图像的api.但是任何建议/想法都会很棒.

I saw stack over flow answers like there is no api for download all images at once. But any suggestion/ideas would be great.

推荐答案

最终得到了解决方案.

Flutter包firebase_storage:^ 3.0.6没有名为listAll()的方法.仅能使用Firebase存储中的getDownloadURL()方法获取单个文件/图像下载URL.

Flutter package firebase_storage: ^3.0.6 has no method called listAll(). Only able to get single file/image download url using getDownloadURL() method from firebase storage.

最近(19小时前,2019年10月16日)flutter团队添加了此功能,以使用listAll()方法获取所有文件和文件夹.以下是git链接.

Recently (19 hours ago, 16th Oct 2019) flutter team has added this functionality to get all files and folders using listAll() method. Below is the git link.

https://github.com/FirebaseExtended/flutterfire/pull/232

需要使用pubspec.yaml中的软件包,如下所示:

Need to use package in pubspec.yaml like below :

firebase_storage:
    git:
      url: git://github.com/danysz/flutterfire.git
      ref: master
      path: packages/firebase_storage

这是临时解决方案,直到他们更新此软件包版本firebase_storage:^ 3.0.6

This is temporary solution until they update this package version firebase_storage: ^3.0.6

Example Code : 

void getFirebaseImageFolder() {
    final StorageReference storageRef =
        FirebaseStorage.instance.ref().child('Gallery').child('Images');
    storageRef.listAll().then((result) {
      print("result is $result");
    });
  }

希望对许多人有用.编码愉快!

Hope it will be useful for many people. Happy coding!

这篇关于Flutter-从Firebase存储中获取所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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