Hi i am using the tmp module to create the temp file, and i need to write that file but i am getting Error.
Here is My code
exports.readhttpsFile = function (req, res) {
var https = require('https'),
tmp=require('tmp'),
fs=require('fs');
var tmpObj = tmp.fileSync({unsafeCleanup:false,postfix: '.xlsx'});
var downloadedFile=tmpObj.name;
var file = fs.createWriteStream(tmpObj.name);
https.get('https://xxxxxxxxx/1495119759202grocer_loose_item_xlsx?alt=media', function (res3) {
var body = '';
res3.on('data', function (chunk) {
file.write(chunk);
});
res3.on('end', function () {
console.log("Read File Done");
res.send("Read File Done");
});
});
};
But i am getting the Error like: ^
TypeError: First argument must be file descriptor
at TypeError (native)
at Object.fs.write (fs.js:775:18)
Can anybody help me on this
via Jeevan
No comments:
Post a Comment