即使在 AngularFire2 的 Firebase 存储中取消上传任务后,快照状态仍为 'running'

Snapshot state is 'running' even after cancelling the upload task in AngularFire2's Firebase Storage

我正在使用 AngularFire2Firebase Storage 中上传文件:

this.task = this.storage.upload(uploadPath, file);

this.task.snapshotChanges()
            .subscribe(snapshot => {
                this.snapshot = snapshot;
            });

它按预期工作,但是,当我通过 cancel() 方法取消 task 时,snapshot 没有改变,因此 staterunning,而不是 cancelled。这是为什么?

this.task.cancel();
// this.snapshot.state === 'running', not 'cancelled'

似乎是一个真正的错误

最后一个事件不会在 snapshotChanges() 上发出,但会在 .then() 承诺中发出

this._task.snapshotChanges()
  .subscribe(snapshot => {
    this.snapshot = snapshot; // To get updates on progress
  });
this._task.then(snapshot => {
  this.snapshot = snapshot; // To know when it is done
}).catch(snapshot => {
  this.snapshot = this._task.task.snapshot; // To know whenever there is an error/cancel from user
});