Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!