Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda