Delete folder with contents from Firebase Storage

2019-01-09 13:06发布

问题:

This question already has an answer here:

  • FirebaseStorage: How to Delete Directory 6 answers

I can easily delete a file within a child reference, but how would I delete the entire folder from Firebase Storage?

let postRef = FIRStorage.storage().reference().child("posts/folderName")
    postRef.deleteWithCompletion { (error) in
        print(error)
    }

Error file does not exists. Any ideas?

回答1:

Long story short, we haven't implemented a recursive (or folder) delete. This topic is covered in another post: FirebaseStorage: How to Delete Directory

For now, we recommend storing a list of files in another source (like the Realtime Database) and deleting files as necessary. You can also perform this type of delete in the Firebase Console (console.firebase.google.com).

In the future, we may offer this sort of functionality, but don't have it fully spec'ed out.