Angular 6 - Getting Download URL For Firebase Storage File After Uploading


Answer :

You should add a finalize() to the pipe, something like:

this.task.snapshotChanges().pipe(   finalize(() => {     this.downloadURL = this.ref.getDownloadURL(); // <-- Here the downloadURL is available.   }) ).subscribe(); 

In the finalize() step, the downloadURL is available, so u can grab him from the ref asynchronously. --UPDATE
You said you are using Angular 6, so I assume you are using the last version of firebase.
They change getDownloadURL() to Observable from Task, So to get the actual URL you just have to subscribe.

this.task.snapshotChanges().pipe(   finalize(() => {     this.ref.getDownloadURL().subscribe(url => {       console.log(url); // <-- do what ever you want with the url..     });   }) ).subscribe(); 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable