I am trying to store my file using Google Firebase storage API but the pipe is getting executed twice. Any ideas to make it triggered one time only?
// def
task: AngularFireUploadTask;
storage: AngularFireStorage;
// code
this.task = this.storage.upload(path, file, { customMetadata });
return this.task.snapshotChanges().pipe(
map(doc => {
console.log('me'); // THIS IS PRINTED TWICE
return doc;
})
);
According to the documentation, you can expect that the pipe will receive multiple snapshots as the upload progresses. Each of these snapshots contain some information about the status of the upload as it progresses over time.
If you just want to know when the upload is complete, take the code from the sample in the documentation, which gets the download URL after the upload is complete:
task.snapshotChanges().pipe(
finalize(() => this.downloadURL = fileRef.getDownloadURL() )
)