Angularfire: [Breaking change] AngularFireStoreReference getMetadata() doesn't return anything

Created on 1 Apr 2020  路  9Comments  路  Source: angular/angularfire

Version info

Angular: 9.1

Firebase: 7.15.0

AngularFire: 6.0.0-rc.2

Node: 10

How to reproduce these conditions

AngularFireStore works fine and my image is uploaded in the right place. Problem is that I can't access anymore the metadata of it with getMetadata() from AngularFireStorageReference.

I noticed that change in the last update :

from

getMetadata: () => from(ref.getMetadata()).pipe(
      observeOn(schedulers.outsideAngular),
      switchMap(() => ref.getMetadata()),
      keepUnstableUntilFirst
),

to

getMetadata: () => of().pipe(
      observeOn(schedulers.outsideAngular),
      switchMap(() => ref.getMetadata()),
      keepUnstableUntilFirst
),

And here it is how I use it right now in my code

goToShow() {
  this.url$ = this.ref.getDownloadURL();
  combineLatest([this.url$, this.ref.getMetadata()])
    .subscribe(([url, meta]) => {
      this.uploaded(createImgRef({
        url,
        ref: meta.fullPath,
        originalFileName: this.originalFileName,
      }));
      this.nextStep('show');
    })
}

Tried to do this.ref.getMetadata().subscribe(console.log()) but nothing is showing in the console.
Am I missing something ?

Most helpful comment

You can do something like that:

 this.firebaseStorage.storage.ref(path).getMetadata()
      .then(meta => meta.customMetadata);

All 9 comments

I'll look into this later today, thanks for helping test the RC.

Can confirm this bug is also in the released 6.0. It was working with -rc.1. getDownloadURL is also affected

Maybe it comes from this change.
Would you recommand a workaround in the meantime ?

Anybody found a workaround or is the only solution to use RC1 atm?

You can do something like that:

 this.firebaseStorage.storage.ref(path).getMetadata()
      .then(meta => meta.customMetadata);

I can confirm that I'm also seeing this on @angular/fire: ^6.0.0 when attempting to do the following:

const transcodeObs = fileRef.getMetadata().pipe(
        tap((x) => console.log(x)),
        switchMap((metadata) => {
          return this.transcodeService.transcode$({
            readPath: metadata.fullPath
          })
        })
      )

same here:

combineLatest([
            this.storage.ref(this.path + fileItem.fileName).getMetadata(),
            this.storage.ref(this.path + fileItem.fileName).getDownloadURL(),
          ])
            .pipe(
              map(url => {
                console.log(url[0]);
                console.log(url[1]);
                return url[0];
              }));

Same issue on 6.0.0

in 6.0.2 this appears to be working again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KLiFF2606 picture KLiFF2606  路  3Comments

itisparas picture itisparas  路  3Comments

StephenFluin picture StephenFluin  路  3Comments

Maistho picture Maistho  路  3Comments

cre8 picture cre8  路  3Comments