如何从Firebase存储中获取图像文件

我想从我的Firebase存储中获取图像。 路径是:images / recipes / test.jpg,我想在从集合的特定路径获取其他数据时创建它。

这是整个代码:

_retrieveData = async() => {
      let fbdata = [];
      let getImageURL = '';

      await Firebase.db.collection('fl_content').get().then(query => {
        query.forEach(doc => {

          firebase.files.ref().child("images/recipes/test.jpg")
          .getDownloadURL()
          .then(url => {
            getImageURL = url;
          });

          fbdata.push({
            id: doc.id,titel: doc.data().titel,beschreibung: doc.data().beschreibung,bild: getImageURL
          });
        })
      });

      this.setState({ fbdata,isLoading: false });
    }

我看到了永无休止的activityIndi​​cator :(。 没有“ firebase.files”部分(直到fbdata.push的开头),我从集合中获取了id,titel和beschreibung。

有人知道,我如何获得直接图像?之后,我想获取图像,该图像在集合中被视为参考。但是首先,直接获取图像会很棒。

第一步的认证部分是公开的!

zhuqing123456789 回答:如何从Firebase存储中获取图像文件

是的,谢谢!我现在知道了。这是我的代码:

_retrieveData = async() => {
      let fbData = [];

      await Firebase.db.collection('recipes').get().then(query => {
        query.forEach(doc => {
          Firebase.storage.ref(doc.data().teaser).getDownloadURL().then(url => {
            fbData.push({
              id: doc.id,titel: doc.data().titel,teaser: url
            });
            this.setState({ fbData,isLoading: false });
          });
        })
      });
    }
本文链接:https://www.f2er.com/3169235.html

大家都在问