Typescript ref.getMetadata未在AngularFireStorage中订阅
我最近更新到AngularFire 6.0,并且AngularFire存储出现问题。上传图像并调用Typescript ref.getMetadata未在AngularFireStorage中订阅,typescript,firebase,google-cloud-firestore,rxjs,angularfire,Typescript,Firebase,Google Cloud Firestore,Rxjs,Angularfire,我最近更新到AngularFire 6.0,并且AngularFire存储出现问题。上传图像并调用ref.getMetadata().subscribe(…)后,似乎没有数据返回。以下是我的代码片段: this.ref = this.afStorage.ref(`${this.location}/tmp/${randomUUID}`); this.task = this.ref.put(imageFile, { customMetadata: { blah: 'blah' } }); this.
ref.getMetadata().subscribe(…)
后,似乎没有数据返回。以下是我的代码片段:
this.ref = this.afStorage.ref(`${this.location}/tmp/${randomUUID}`);
this.task = this.ref.put(imageFile, { customMetadata: { blah: 'blah' } });
this.uploadProgress = this.task.percentageChanges();
this.task
.snapshotChanges()
.pipe(finalize(() => {
this.ref.getMetadata().subscribe(
(res: any): void => {
imgControl.setValue(res.fullPath);
imgControl.updateValueAndValidity();
this.setPreviewSrc(imageFile);
this.uploading = false;
},
(error: any): void => {
console.error(error);
this.error = true;
this.errorMessage = 'Something went wrong. Please retry.';
}
);
})
).subscribe();
我试着调用
this.ref.getDowloadUrl().subscribe(…)
,效果很好。让我知道我遗漏了什么。试着使你的finalize函数异步,像这样:.pipe(finalize(async()=>{
并让我知道它是否有效Hello@Jean Richard Désiré,你试过我上面提到的解决方案吗?试着使你的finalize函数异步,像这样:.pipe(finalize(async()=>{
并让我知道它是否有效Hello@Jean Richard Désiré,你尝试过我上面提到的解决方案吗?