ref.getMetadata未在AngularFireStorage中订阅

时间:2020-04-19 18:39:19

标签: typescript firebase google-cloud-firestore rxjs angularfire

我最近更新到了AngularFire 6.0,并且AngularFireStorage遇到了问题。上传图像并调用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(...),但该方法有效。让我知道我在想什么。

0 个答案:

没有答案