Skip to content

Instantly share code, notes, and snippets.

@saurav12994
Created July 31, 2018 05:42
Show Gist options
  • Save saurav12994/4af73ffe24aff3fde3c9237aebe38c38 to your computer and use it in GitHub Desktop.
Save saurav12994/4af73ffe24aff3fde3c9237aebe38c38 to your computer and use it in GitHub Desktop.
Delete Folder in Firebase cloud storage using Cloud Function
I hava a folder inside CustomerDocuments in Firebase cloud storage name xyz which contains many types of file like .pdf,.txt,.png etc.
function deletefromstorage(quoteiddelete)
{
//quoteiddelete contains folder name in CustomerDocuments which we want to delete.
const Storage = require('@google-cloud/storage');
const storage = new Storage();
const srcBucketName = 'abc.apot.com';
return storage.bucket(srcBucketName).deleteFiles({
prefix: 'Customerdocuments/'+quoteiddelete+'/'
}, function(err) {
if (err) {
console.log(err);
} else {
console.log(`All the Firebase Storage files in have been deleted`);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment