Here is the code:
var fs = require('fs') var request = require('request'); request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png')) It saves the data (file) received by reference to the file .. :)
My questions are:
How to finish writing data to the file immediately read them again using createReadStream ??
How to track or wait that the data in the file is already 100% all written before reading ??
Is it possible to hang a promise on this request or pipe? or otherwise rewrite it?
- Suppose there are a lot of links from which the data will be written to files in a loop - And then how can I immediately read them again if the loop is asynchronous ??