I am creating a Flutter app that uses Firebase storage. I have the structure of a collection with the user data in Firestore and a folder on the Firebase storage with named after the uid of the current user. However if the user want to delete the account all the images have to be removed. Is there a way to remove an entire directory in Firebase storage through Flutter?
The files are uploaded as such:
// Upload img
firebase_storage.Reference storageRef = firebase_storage
.FirebaseStorage.instance
.ref()
.child('images/users/' + uid + '/mealImages/' + fileName);
firebase_storage.UploadTask uploadTask = storageRef.putFile(imageFile);
// Remove img where uid=aaa and fileName=bbb.jpg
await firebase_storage.FirebaseStorage.instance
.ref()
.child(
'images/users/aaa/mealImages/bbb.jpg')
.delete();