Skip to content

Instantly share code, notes, and snippets.

@tmartineau
Created August 22, 2012 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmartineau/3421484 to your computer and use it in GitHub Desktop.
Save tmartineau/3421484 to your computer and use it in GitHub Desktop.
Example of wrtieStream I am trying on Nodjitsu
var oldName = req["headers"]["x-file-name"],
tmpPath= path.join(__dirname, '../temp/' + oldName),
ws = fs.createWriteStream(tmpPath),
req.pipe(ws);
req.on('error', function(err) {
console.log(err);
});
req.on('end', function() {
fs.readFile(tmpPath + '/' + oldName, function(err, doc) {
if(err) console.log('Error: ', err);
console.log(doc);
fs.unlink(tmpPath + '/' + oldName);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment