thedeveloper123
thedeveloper123

Reputation: 7

Firebase upload is not getting download URL

I am working on a function where I am going to upload image from emulator which sends to firebase storage. I want to get the downloadURL and to be placed into firebase firestore but, I am not retrieving the download URL. Would appreciate help.. thank you! I am currently doing my project with firebase storage and 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)
      })
});
    
  });
}

Upvotes: 0

Views: 46

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33335

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

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

Upvotes: 1

Related Questions