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

192
Views
almacenamiento de base de fuego carga de archivos múltiples

Estoy usando angular 13.0 y firebase 9.4. Quiero cargar varios archivos en el almacenamiento y crear una matriz downloadURLs[]. Una vez que se cargan todos los archivos, quiero enviar la matriz a Firestore. No puedo capturar la finalización de todos los eventos de carga con las URL de descarga completas[]. Aunque todas las cargas se completan sin ningún error.

Mi código es el siguiente

//Código para subir un solo archivo

 private async uploadEachFile(fileToUpload: File, filePath: string): Promise<string> { let downloadURL: string; const storageRef = this.storage.ref(filePath); const uploadTask = this.storage.upload(filePath, fileToUpload); //upload file await uploadTask.snapshotChanges().pipe( finalize(() => { storageRef.getDownloadURL().subscribe(fileURL => { downloadURL = fileURL; return downloadURL; });})).subscribe(); return downloadURL; }

//Código para iterar todos los archivos

 private addFilesToStorage(selectedFiles?: File[] ) { let newFileName; //define file name let filePath; //define file path let downloadURLs: string[]; if(selectedFiles) { const sfLastIndex = selectedFiles.length - 1; for (let sfIndex = 0; sfIndex <= sfLastIndex; sfIndex++) { //iteration const selectedFile = selectedFiles[sfIndex]; newFileName = selectedFile.name + '-' + this.dateToString(new Date(),'yyMMddhhmmss'); filePath = 'images/' + newFileName; this.uploadEachFile(selectedFile, filePath) .then(downloadURL =>{ if(downloadURLs) { downloadURLs.push(downloadURL); } else { downloadURLs = [downloadURL]; } if(sfIndex === sfLastIndex) { console.log(downloadURLs); // <- here NOT able to capture all URLs pushURLsToFirestore(downloadURLs); //call a function to store an array } }); } }
about 4 years ago · Juan Pablo Isaza
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!