Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- var Busboy = require('busboy');
- function processUpload(req, res) {
- var busboy = new Busboy({headers: req.headers});
- busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
- file.on('data', function(data) {
- console.log('File [' + fieldname + '] got ' + data.length + ' bytes');
- });
- file.on('end', function() {
- console.log('File [' + fieldname + '] Finished');
- });
- });
- busboy.on('field', function(fieldName, fieldValue, fieldNameTruncated, fieldValueTruncated) {
- console.log('Field ', fieldName, 'with value', fieldValue);
- });
- busboy.on('finish', function() {
- console.log('Done parsing form!');
- res.writeHead(303, { Connection: 'close', Location: '/' });
- res.end();
- });
- req.pipe(busboy);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement