Reputation: 441
and I wanna delete everything on that file.
This is what I've tried so far:
FirebaseStorage.instance.ref().child("User ($uid)/ads").delete();
FirebaseStorage.instance.ref().child("User ($uid)/ProfilePic").delete();
the second line deletes the ProfilePic
, but the first line returns an error.
I'm new to firebase and flutter so bear with me.
Upvotes: 1
Views: 324
Reputation: 2015
There is no firebase API to delete all the files with a certain prefix i.e. files you see in the console within a certain folder.
One way to achieve this is by using listAll()
method to fetch all the files with certain prefix and delete them individually later.
Flutter firebase storage listAll()
method is currently available in dev
version of package, in version 5.0.0-dev.1
, which you can use as shown below:
firebase_storage.ListResult result =
await firebase_storage.FirebaseStorage.instance.ref().listAll();
After using listAll()
, you'll get all the files and then you can delete them individually.
Additionally, you can delete files on your backend server also.
Upvotes: 1