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();
↧
Angular Getting download URL for Firebase Storage file after uploading
↧