Hey I am a real beginner with node js so bear with me. I am trying to download a file ( an image) this is the code I have :
function downloadFileFromURL( url, callback )
{
file_name = path.basename(url);
var wstream = fs.createWriteStream(file_name);
wstream.on('error', function (err) {
console.log(err, url);
});
wstream.on( 'close', function(){
console.log( "finished downloading: ", url, this.path );
});
request(img_url).pipe( wstream );
}
if I parse a blog feed with my app, this function downloads about half of the images. I can see the images fine from a browser. The files get created but some of them stay at 0 bytes.
the example feed I am parsing is: http://feeds.feedburner.com/ButDoesItFloat?format=xml
I saw this question on here: Writing image to local server which is similar and would love to see how its done with node-request