In Node Express, I am reading a locally saved zip file and sending it to a Java servlet using request module.
var req = require('request');
//Define a read stream from our source zip file
var source = fs.createReadStream('abc.zip');
//Send our data via POST request
source.pipe(req.post('http://myhost:8080/myservlets/uploadzip'));
//Can I cleanup abc.zip here?
After the zip is uploaded, I need to clean up the zip from the node server. The challenge that I am facing is that how to find that zip upload has completed? Is there a way to get a promise when upload completes or define a callback, so that I can put the zip cleanup code only after upload completes.