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

99
Views
Mi ejemplo.downloadURL devuelve un indefinido

Simplemente estoy tratando de probar la carga de imágenes y quiero mostrar la imagen cargada. Mi código se ve así:

 function uploadFile(files){ const storageRef = firebase.storage().ref(); //this references the firebase storage const horseRef = storageRef.child("horse.jpg"); const file = files.item(0); //will return a list so lets take the first item const task = horseRef.put(file); //to upload the file we call the put file console.log(task); task.then(snapshot => { //returns a buncha data including a snapshot url const url = snapshot.downloadURL document.getElementById("upload").setAttribute("src", url) }); }

Pero snapshot.downloadURL devuelve un valor indefinido. ¿Me puedes ayudar?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No hay ninguna propiedad downloadURL en la instantánea que sea un UploadTaskSnapshot . Debe usar el método getDownloadURL() en la referencia de almacenamiento para obtener la URL. Intente refactorizar el código como se muestra a continuación:

 task.then(async (snapshot) => { const url = await snapshot.ref.getDownloadUrl() document.getElementById("upload").setAttribute("src", url) });
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!