Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
ionic Angular 9 wait until file download url is available

I am using ionic 5 and angular 9 to upload a data url to firebase storage. My code works good but i am not sure how to wait until the download url is avaialble.

below is the code

uploadToFireStore(imageData){
    const storage = getStorage();
    const storageRef = ref(storage, (new Date().getTime().toString()));
    uploadString(storageRef, imageData, 'data_url').then((snapshot) => {
      getDownloadURL(snapshot.ref).then((downloadURL) => {
        console.log('File available at', downloadURL);
        this.downloadURL = downloadURL
      });
    });
  }

I am calling it in my camera plugin like this

this.uploadToFireStore(base64Image)
console.log("updated with url:", this.downloadURL)

currently the download url is printed later and my code is not waiting for download url to be there. I need this url to upload to my RTDB so please advise how can i do it without moving the code into this part

getDownloadURL(snapshot.ref).then((downloadURL) => {
...
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You probably just need to return your promise chain:

uploadToFireStore(imageData){
    const storage = getStorage();
    const storageRef = ref(storage, (new Date().getTime().toString()));
    return uploadString(storageRef, imageData, 'data_url').then((snapshot) => {
      return getDownloadURL(snapshot.ref).then((downloadURL) => {
        console.log('File available at', downloadURL);
        this.downloadURL = downloadURL
      });
    });
  }

Then you can do this:

this.uploadToFireStore(base64Image).then(() => {
   console.log("updated with url:", this.downloadURL)
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda