NodeJS Secure File Removal Utility
Use Node JS to securely delete files on your server with Unix's shred
command.
How to Install
npm install shredfile
Licence info
Licensed under the MIT License:
Getting Started
All of the values listed in the example below represent the default values for their respective configuration item.
You can simply do this:
var shredfile = require('shredfile')();
And, you'll be good to go.
BUT: If you want more control, you can specify all sorts of options.
var shredfile = require('shredfile')({
shred_path: '/usr/bin/shred',
force: false,
iterations: 3,
bytes: null,
remove: true,
zero: true,
debug_mode: false
});
Here is a non-default values example (to help you get an idea of what the proper-looking values should be):
var shredfile = require('shredfile')({
shred_path: '/usr/local/bin/shred',
force: true,
iterations: 25,
bytes: '70M',
remove: false,
zero: false,
debug_mode: true
});
API
.shred(files, end_cb, status_cb)
This method allows you to shred a one or many files.
Parameters:
files
required (string or array) A path (string) or list paths (array) to file(s) you want to be shredded.end_cb
(function) Will be called when the shred is complete. It takes 2 parameters:err
(string or null) A standard error message string (null if no error)file
(string) The original files
parameter passed into this shred
method.status_cb
(function) Will be called everytime the status of a file is changed (ex. renaming and each overwrite iteration). It takes 4 parameters:action
(string) This will be either 'overwriting' or 'renaming'progress
(float) The percentage of the specific action that is complete (ex. 0.66)file
(string) File name of the file that is currently being acted uponactive_file_path
(string) Full path to the file that is currently being acted upon
Examples:
Single File:
shredfile.shred('/a/picture/for_example.jpg', function(err, file) {
if(err) {
console.log(err);
return;
}
console.log("File has been shredded!");
});
Multiple Files:
shredfile.shred(['/a/picture/for_example.jpg','/a/different/file.dat'], function(err, file) {
if(err) {
console.log(err);
return;
}
console.log("Files have been shredded!");
}, function(action,progress,file,path) {
progress = (Math.round((progress * 10000)) / 100);
self.settings.logger.debug(action + ' ' + file + ': ' + progress + '%');
});