FirebaseStorage: Deleting a Directory

9,347 views
Skip to first unread message

Ishaq

unread,
Jun 10, 2016, 10:36:01 AM6/10/16
to Firebase Google Group
is it possible to delete a directory on Firebase Storage, something like this always returns error 400:

// Swift code
let
storageRef = FIRStorage.storage().reference().child("path/to/directory")

storageRef.deleteWithCompletion { (error) in

   print("error: \(error)")

   print("------------")

}


removing each file in the directory one by one seems to wasteful, specially when there can be 100s of files in there.

Thank you.

--
MI

Kato Richardson

unread,
Jun 10, 2016, 4:00:16 PM6/10/16
to Firebase Google Group

Hi Ishaq,

Great to meet you. There isn’t a way to delete a directory from the Storage SDK. Generally speaking, you want to store a list of your files somewhere, such as Database, and use that reference to delete en masse.

Note that as a non-scalable answer, you can delete a path from the CLI using the GCS tools:

gsutil rm gs://bucket/subdir/**

And it looks like GCS also has an API method for listing contents of a directory if that’s needed.

I hope that helps!

☼, Kato


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1d975b85-fc3c-4ae3-8620-5588d5fd94d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Ishaq

unread,
Jun 10, 2016, 7:36:30 PM6/10/16
to Firebase Google Group
bummer! Thank you very much for your reply Kato. 

I do have the list of files in a database, but deleting each file one by one seems very wasteful, specially in my use case the directory could easily have 100s (may be even 1000s) of files. Is there a public feature list where I could add it as a ticket? I believe it really should be a part of the core SDK.

Thank you again for the reply. Have a nice day.

--
MI

Jacob Wenger

unread,
Jun 10, 2016, 8:40:09 PM6/10/16
to fireba...@googlegroups.com
Feature requests can be filed here, although there is no public tracker.

Jacob

Ishaq

unread,
Jun 11, 2016, 11:33:58 AM6/11/16
to Firebase Google Group
Thanks Jacob, I have filed a feature request, though since it is not public, can't share the link here.

--
MI

Luis Cabrera

unread,
Jul 20, 2017, 10:20:40 AM7/20/17
to Firebase Google Group

Was this feature request implemented? I've been looking for this functionality but haven't found an answer yet. 
Reply all
Reply to author
Forward
0 new messages