1

This is how my DB looks like: enter image description here

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.