Search code examples
angularangularfire2

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?


Solution

  • 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();
    }