【问题标题】:Firebase storage - uploaded image, no download urlFirebase 存储 - 上传图片,没有下载网址
【发布时间】:2021-04-13 15:45:48
【问题描述】:

我使用 firebase 控制台将图像上传到存储。

看下面的截图

图像预览未加载错误:加载预览时出错 我在文件位置下找不到下载网址。

任何人都可以帮助解决缺少的问题吗?我期待某个地方的下载网址。

规则是默认的:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

谢谢

【问题讨论】:

    标签: firebase download upload storage


    【解决方案1】:

    使用 Storage API,您可以尝试检索文件的下载 URL https://firebase.google.com/docs/reference/android/com/google/firebase/storage/StorageReference#getDownloadUrl() 它返回一个 Promise 对象。 例如

    const storage = firebase.storage();
    const imageRef = storage.ref().child('app-icon-48x48.png'); //if any subfolder include it in the path
    imageRef.getDownloadURL().then(function (url) {
      console.log(url);
    } );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-08
      • 2019-04-20
      • 2019-11-04
      • 2021-01-13
      • 2018-05-30
      • 2018-07-29
      • 2020-10-05
      • 2023-03-06
      相关资源
      最近更新 更多