我使用file-upload.component.ts,当在另一个组件中用作子组件时,它工作正常,但是在对话框中(作为子组件)使用时,它无法按预期工作。
startUpload(event: FileList) {
const file = event.item(0);
const ref = this.storage.ref(this.imagePath);
this.task = this.storage.upload(this.imagePath, file);
// snapshotChanges() doesn't complete in Angular material dialog.
this.snapshot = this.task.snapshotChanges().pipe(
finalize(async () => {
this.downloadURL = await ref.getDownloadURL().toPromise();
})
);
}
该文件已上传到Firebase存储,但是snapshotChanges()无法运行,并且我没有任何下载URL。