Skip to content

Instantly share code, notes, and snippets.

@tranphuoctien
Forked from JacobHsu/wget.js
Created March 21, 2016 11:55
Show Gist options
  • Save tranphuoctien/07442b717ea59ecf4645 to your computer and use it in GitHub Desktop.
Save tranphuoctien/07442b717ea59ecf4645 to your computer and use it in GitHub Desktop.
Downloading using wget #nodejs
//note: http://www.html-js.com/article/1961
// Function to download file using wget
var download_file_wget = function(file_url) {
// extract the file name
var file_name = url.parse(file_url).pathname.split('/').pop();
// compose the wget command
var wget = 'wget -P ' + DOWNLOAD_DIR + ' ' + file_url;
// excute wget using child_process' exec function
var child = exec(wget, function(err, stdout, stderr) {
if (err) throw err;
else console.log(file_name + ' downloaded to ' + DOWNLOAD_DIR);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment