首页 > 解决方案 > Angular Firebase - 从存储中下载文件

问题描述

我正在尝试使用 firebase 存储来下载文件。我有一个包含电影 URL 的实时数据库。我已经使用应该下载文件的方法创建了服务。我按照firebase docs中的所有内容做了所有事情,但我的方法没有做任何事情。

firebase 文档:https ://firebase.google.com/docs/storage/web/download-files?authuser=1#download_data_via_url

我的代码如下:

  public downloadMovie() {
    this.fireStorage.storage.refFromURL("https://example_link_for_firebase.com/b/bucket/o/images%20stars.jpg").getDownloadURL().then(url => {
      const xhr = new XMLHttpRequest();
      xhr.responseType = "blob";
      xhr.onload = function(event) {
        const blob = xhr.response;
      };
      xhr.open("GET", url);
      xhr.send();
    })
  }

有任何想法吗?

标签: javascriptangularfirebasefirebase-storage

解决方案


推荐阅读