FirebaseStorage: Deleting a Directory and all its contents using node.js

510 views
Skip to first unread message

Luis Cabrera

unread,
Jul 14, 2017, 3:28:01 PM7/14/17
to Firebase Google Group
A similar question was asked in this group about a year ago and I'm wondering if there is a solution now.


I am able to delete a file using node.js example below:

But I'm not able to delete a folder and all it's contents. 

Here's my storage file structure and code (simplified):

[myfirebasestorageapp].appspot.com/users/user1/file1.png

'users' is a folder
'user1' is a folder
'file1.png' is a file under user1

When I try to delete a specific file in storage (i.e. file1.png) with the code below, everything works. The file gets deleted:

const deletefilePath = 'users/user1/file1.png';
const gcFile = bucket.file(deletefilePath);
gcFile.delete((err,res)=>console.log(err||res));

But if I want to delete the whole folder for user1 it doesn't work:

const deletefilePath = 'users/user1/';
const gcFile = bucket.file(deletefilePath);
gcFile.delete((err,res)=>console.log(err||res));

Any ideas? Am I missing something? 

Luis Cabrera

unread,
Jul 19, 2017, 11:05:45 AM7/19/17
to Firebase Google Group
I want to be able to delete a folder (and contents) programmatically. The official Firebase console already does it and I'm wondering how it is done in code.

Reply all
Reply to author
Forward
0 new messages