Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete folder with contents from Firebase Storage [duplicate]

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?

like image 814
arvidurs Avatar asked Jul 05 '16 22:07

arvidurs


People also ask

Can I delete a folder in Firebase storage?

After uploading files to Cloud Storage, you can also delete them. Note: By default, a Cloud Storage bucket requires Firebase Authentication to perform any action on the bucket's data or files. You can change your Firebase Security Rules for Cloud Storage to allow unauthenticated access.

How do I remove items from storage in Firebase?

To delete a file, first create a reference to that file. Then call the delete() method on that reference, which returns a Promise that resolves, or an error if the Promise rejects.

How do I delete multiple files from Firebase storage?

There is no API for bulk or batch deleting files in Cloud Storage. You will have to delete each one individually as described in the documentation.

How do I remove files from Firebase storage with URL?

To delete a file from the firebase storage we need a reference to store the file in storage. As we only have the file URL we need to create a reference object of the file in firebase storage and then delete that file. Get the reference to the storage using refFromUrl method from firebase. storage.


1 Answers

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 either storing a list of files in another source (like the Realtime Database) or using the list API, and then 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.

like image 129
Mike McDonald Avatar answered Oct 21 '22 07:10

Mike McDonald