Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140131

Angular Getting download URL for Firebase Storage file after uploading

$
0
0
import { AngularFireStorage, AngularFireStorageReference, AngularFireUploadTask } from '@angular/fire/storage';
import { finalize } from 'rxjs/operators';

ref:AngularFireStorageReference;
task:AngularFireUploadTask;
downloadURL:Observable<string>;

const file = event.target.files[0];
const id = Math.random().toString(36).substring(2);
this.ref = this.storage.ref(id);
this.task = this.ref.put(event.target.files[0]);

this.task.snapshotChanges()
.pipe(
      finalize(() => {
        this.downloadURL = this.ref.getDownloadURL();
        this.downloadURL.subscribe(downloadURLResponse => {
           console.log('downloadURL', downloadURLResponse);
        });
      }),
 )
.subscribe();

Viewing all articles
Browse latest Browse all 140131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>