Skip to content

Instantly share code, notes, and snippets.

@chrismcv
Created January 26, 2012 11:57
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 chrismcv/1682443 to your computer and use it in GitHub Desktop.
Save chrismcv/1682443 to your computer and use it in GitHub Desktop.
Gzip upload with formidable
var receivedFile, form = new formidable.IncomingForm();
form.keepExtensions = true;
form.on('file', function (field, file) {
receivedFile = file;
}).on('end', function () {
var inp = fs.createReadStream(receivedFile.path);
var out = fs.createWriteStream(receivedFile.filename);
inp.pipe(gzip).pipe(out);
fs.unlink(receivedFile.path, function (err) {
if (err) console.log(err);
else {
response.end('received files:\n\n ' + receivedFile);
}
});
});
form.parse(request);
} else next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment