【问题标题】:Firebase upload is not getting download URLFirebase 上传未获取下载 URL
【发布时间】:2020-12-05 01:27:53
【问题描述】:

我正在开发一个功能,我将从模拟器上传图像并发送到 Firebase 存储。我想获取 downloadURL 并将其放入 firebase firestore,但是我没有检索下载 URL。将不胜感激帮助..谢谢! 我目前正在使用 firebase 存储和 firestore,ionic v5 进行我的项目。

uploadToStorage(){
  let options: CameraOptions ={
    quality : 100,
    destinationType:this.camera.DestinationType.DATA_URL,
    encodingType : this.camera.EncodingType.JPEG,
    sourceType : this.camera.PictureSourceType.PHOTOLIBRARY
  }
  this.camera.getPicture(options).then((data)=>{
    var storage = this.store.ref('/AAA');
    var photoRef = storage.child(this.mAuth.auth.currentUser.uid);
    let base64img = 'data:image/jpeg;base64' + data;
    var message = data;
    photoRef.putString(message , 'base64', { contentType: 'image/jpg' }).then((savedPicture) => {
      savedPicture.downloadURL().subscribe((datas)=>{
        console.log(datas)
      })
});
    
  });
}

【问题讨论】:

  • 请编辑问题以准确解释此代码在运行时实际执行的操作与您的预期不同。添加更多日志记录以跟踪其行为。

标签: javascript firebase ionic-framework firebase-storage


【解决方案1】:
savedPicture.snapshot.ref.downloadURL().then((datas)=>{
   console.log(datas)
})

https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress

【讨论】:

    猜你喜欢
    • 2021-07-17
    • 2019-01-17
    • 2018-01-24
    • 2018-12-30
    • 2017-07-08
    • 2019-03-13
    • 2018-12-28
    • 2020-01-29
    • 2020-11-02
    相关资源
    最近更新 更多