-
-
Save tranphuoctien/07442b717ea59ecf4645 to your computer and use it in GitHub Desktop.
Downloading using wget #nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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