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

205
Views
firebase.storage().ref().getDownloadURL() no se ejecutará

Estoy tratando de cargar una imagen en Firebase Storage y guardar la URL de descarga en Firestore, pero cuando mi código se está ejecutando, .getDownloadURL() no se ejecutará. La imagen se sube, pero después de eso, no pasa nada. Mi código está abajo. He probado con varias imágenes.

 const task = firebase.storage().ref('/hendingar/' + img.name).put(img) task.then((snapshot) => { console.log('Img ') snapshot.ref.getDownloadURL((url) => { console.log('Url') firebase.firestore().collection('hendingar').add({ title: title, description: description, start: start, end: end, place: infoPlace, prices: temp_arr, img: url, }).then(() => { console.log('Success') }).catch((error) => { console.error(error) }) }) })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No está obteniendo ningún resultado o registro después de console.log('Img ') porque no está encadenando la promesa correctamente. Debe llamar a getDownloadURL() antes de encadenar .then() . Vea el código a continuación:

 const task = firebase.storage().ref('/hendingar/' + img.name).put(img) // Uploads the file to Firebase Storage. task.then((snapshot) => { console.log('Img') // You can also put the creation of Firestore Document here. // (If you want it to create the document before getting the download URL.) // Calls the `getDownloadURL()` method. snapshot.ref.getDownloadURL() .then((url) => { // Returns the Download URL from Firebase Storage. console.log('Url') console.log(url) // You can put this either here or before getting download URL. firebase.firestore().collection('hendingar').add({ title: title, description: description, start: start, end: end, place: infoPlace, prices: temp_arr, img: url, }).then(() => { console.log('Success') }).catch((error) => { console.error(error) }) }) }) .catch((error) => { // Logs error if there's an error uploading of file. console.log(error) })

Dejo algunos comentarios en el código de arriba para una mejor comprensión. Para obtener más información, puede consultar esta documentación .

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!