I want to download a image file to server first, then upload this file to other server.
If there is no download file step, it will be very simple
var fs = require('fs');
var path = '/tmp/test.png';
var formData = {
method: POST,
url: 'http://127.0.0.1:3000',
json: true,
formData :{file: fs.createReadStream(path)}
};
request(formData, function(err, res, body){
console.log("successful");
});
However, for the situation with download image file;
I don't want to save the file first, through the format like request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')). and then repeat fs.createReadStream.
Is there any method how can I get the file stream, so I can use the file stream directly to constitute formData;