angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

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

Open ioaNikas opened this issue 6 years ago • 9 comments

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 ?

ioaNikas avatar Apr 01 '20 12:04 ioaNikas

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

jamesdaniels avatar Apr 02 '20 15:04 jamesdaniels

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

vandres avatar Apr 05 '20 11:04 vandres

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

GrandSchtroumpf avatar Apr 06 '20 07:04 GrandSchtroumpf

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

Benny739 avatar Apr 12 '20 13:04 Benny739

You can do something like that:

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

N-Andronopoulos avatar Apr 12 '20 13:04 N-Andronopoulos

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
          })
        })
      )

uncvrd avatar Apr 21 '20 19:04 uncvrd

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];
              }));

Diex avatar May 01 '20 20:05 Diex

Same issue on 6.0.0

IvanBean avatar May 05 '20 01:05 IvanBean

in 6.0.2 this appears to be working again

Benny739 avatar Jul 01 '20 23:07 Benny739