I am currently working on a project to upload multiple image files to Firebase Storage and then store their download URLs in a single array within Firestore.
uploadImages(name, images) {
for (let i = 0; i < images.length; i++) {
const file = images[i].file;
const path = `${name}/${new Date().getTime()}_${file.name}`;
this.task = this.storage.upload(path, file);
let snapshot = this.task.task.snapshot;
this.task.snapshotChanges().pipe(
finalize(() => {
snapshot.ref.getDownloadURL().then(downloadUrl => {
this.db.collection('test').doc()....
HOW CAN I STORE ALL DOWNLOAD URLS IN AN ASCENDING ARRAY?
.then(() => {
console.log('Image uploaded successfully.');
})
.catch(error => {
throw new Error('Error uploading image:' + error);
});
});
})
).subscribe(snap => snapshot = snap);
}
}
While my current code retrieves the download URL for each image, I am unsure of how to efficiently save them into one ascending array.