Tuesday, 15 September 2015

javascript - require filename while downloading file using request module nodejs -



javascript - require filename while downloading file using request module nodejs -

i using request module in nodejs download file(only image file) using this,

request('http://google.com/doodle.png').pipe(fs.createwritestream('doodle.png')),

or say

request(url).pipe(fs.createwritestream(filename)),

but have url available , have required save file actual name, have required found filename given url,

please suggest me method donot extracted lastly part of url

thanks in advance...

a simple solution might be:

var path = require('path'); var fs = require('fs'); // ... var filename = path.basename(url); request(url).pipe(fs.createwritestream(filename));

javascript node.js request

No comments:

Post a Comment