Skip to content

Instantly share code, notes, and snippets.

@robertklep
Created May 23, 2013 17:47
Show Gist options
  • Save robertklep/5637962 to your computer and use it in GitHub Desktop.
Save robertklep/5637962 to your computer and use it in GitHub Desktop.
var restify = require('restify');
var server = restify.createServer();
server.use(function(req, res, next) {
req.on('data', function(chunk) {
console.log('Received %d bytes of data', chunk.length);
});
req.on('end', function(chunk) {
console.log('Reading request body done');
next();
});
});
server.post('/', function(req, res) {
res.send('done');
});
server.listen(3012);
@maumercado
Copy link

Hello Robert I hope not to bother you, but Im trying to build a simple rest with user crud and file uploads I want to be able to receive json requests and parse them to create users but for file uploads I want to handle the file upload with a write stream and pipe instead of parsing the req.body, how can I do this?

If I set jsonBodyParser the upload wont work but the user crud will work no problems, but if I remove the jsonBodyParser the user crud wont work at all, so how would I parse the request to create the user via json but the upload file works like a charm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment