Ranika Nisal
Ranika Nisal

Reputation: 980

Deleting files using DownloadURL in AngularFire2

Using AngularFire2 5.0.0-rc.6 and Angular 5.2.11 , is there any way to Delete a file from a Firebase storage Folder using the downloadURL?

Upvotes: 3

Views: 1763

Answers (1)

SiddAjmera
SiddAjmera

Reputation: 39432

Yes of course. AngularFireStorage has a storage object on it with a method named refFromURL on it. You can call it with your Download URL. This will return an instance of type firebase.storage.Reference on which you can then call delete. This returns a Promise<any> which you can return if you want.

Try this:

constructor(private storage: AngularFireStorage) { }

....

delete(downloadUrl) {
  return this.storage.storage.refFromURL(downloadUrl).delete();
}

Upvotes: 9

Related Questions