How do I get the URL of a Firebase Storage photo?

0

Good morning everyone, I'm having a hard time capturing the URL of a particular photo that is sent to firebase storage. The client registration works perfectly, the image upload is also done correctly. So I move to the variable client.foto receive the myPhotoURL that stores the URL of the photo, but it is not saving to the database, so I will not be able to view the photo later.

  //função do upload de fotos
  private uploadPhoto(): void {
   this.myPhotosRef.child(this.generateUUID()).child('myPhoto.png')
   .putString(this.Picture, 'base64', { contentType: 'image/png' })
   .then((savedPicture) => {
    //aqui a myPhotoURL recebe a URL da foto
    this.myPhotoURL = savedPicture.downloadURL;
  });
 }


//função de cadastro de cliente
adicionarCliente() {
  this.cliente.clienteFinalizado = true;
  this.clienteProvider.adicionarCliente(this.cliente);
  //faz o upload da foto 
  this.uploadPhoto();
  //após upload concluído, a variável foto recebe a URL da foto no storage
  this.cliente.foto  = this.myPhotoURL;
  this.toastCadastro();
 }
    
asked by anonymous 22.09.2018 / 15:23

0 answers