Skip to content

Instantly share code, notes, and snippets.

@bogdanpetru
Created November 16, 2015 08:41
Show Gist options
  • Save bogdanpetru/89442e8239404f2807a9 to your computer and use it in GitHub Desktop.
Save bogdanpetru/89442e8239404f2807a9 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var http = require('http');
var ROOT = '/';
var dataString1 = "img1,img2,img3";
function download(list, index){
var file = list[index].trim();
var url = ROOT + file;
var writeStream = fs.createWriteStream( './' + file);
http.get(url, function(response){
response.pipe(writeStream);
console.log(file, 'Done \n');
if( list.length > index ){
download(list, ++index);
}
});
}
download(data1, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment