angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.64k stars 2.2k forks source link

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

Closed ioaNikas closed 3 years ago

ioaNikas commented 4 years ago

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 ?

jamesdaniels commented 4 years ago

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

vandres commented 4 years ago

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

GrandSchtroumpf commented 4 years ago

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

Benny739 commented 4 years ago

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

N-Andronopoulos commented 4 years ago

You can do something like that:

 this.firebaseStorage.storage.ref(path).getMetadata()
      .then(meta => meta.customMetadata);
uncvrd commented 4 years ago

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
          })
        })
      )
Diex commented 4 years ago

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];
              }));
IvanBean commented 4 years ago

Same issue on 6.0.0

Benny739 commented 4 years ago

in 6.0.2 this appears to be working again