首页 > 解决方案 > Firebase 上传未获取下载 URL

问题描述

我正在开发一个功能,我将从模拟器上传图像并发送到 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)
      })
});
    
  });
}

标签: javascriptfirebaseionic-frameworkfirebase-storage

解决方案


savedPicture.snapshot.ref.downloadURL().then((datas)=>{
   console.log(datas)
})

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


推荐阅读