Created
November 16, 2011 16:30
-
-
Save artcommacode/1370557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.create = function(req, res, next){ | |
req.form.on('fileBegin', function(name, file){ | |
console.log(file); | |
console.log(name); | |
}); | |
req.form.on('progress', function(bytesReceived, bytesExpected){ | |
if (bytesExpected > app.settings.maxUpload) { | |
next(new Error('File larger than ' + app.settings.maxUpload/1024 + ' megabytes.')); | |
} | |
}); | |
req.form.complete(function(err, fields, files){ | |
if (err) { | |
console.log(err); | |
res.redirect('back'); | |
} else { | |
console.log('\nuploaded %s to %s', files.image.filename, files.image.path); | |
console.log(fields); | |
res.redirect('back'); | |
} | |
}); | |
req.form.on('error', function(){ | |
console.log('error'); | |
}); | |
}; | |
///////////// | |
Error: File larger than 2048 megabytes. | |
at IncomingForm.<anonymous> (/srv/www/node/ithrowu/controllers/throws.js:16:12) | |
at IncomingForm.emit (events.js:67:17) | |
at IncomingForm.write (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:137:8) | |
at IncomingMessage.<anonymous> (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:91:12) | |
at IncomingMessage.emit (events.js:81:20) | |
at HTTPParser.onBody (http.js:121:23) | |
at Socket.ondata (http.js:1019:22) | |
at Socket._onReadable (net.js:683:27) | |
at IOWatcher.onReadable [as callback] (net.js:177:10) | |
{ size: 0, | |
path: '/tmp/79e0f46b6002d7384d4e8db0a53a3d18.m4a', | |
name: 'thucydidesII-58.m4a', | |
type: 'audio/x-m4a', | |
lastModifiedDate: null, | |
_writeStream: null, | |
length: [Getter], | |
filename: [Getter], | |
mime: [Getter] } | |
image | |
POST /throws 21 | |
Error: File larger than 2048 megabytes. | |
at IncomingForm.<anonymous> (/srv/www/node/ithrowu/controllers/throws.js:16:12) | |
at IncomingForm.emit (events.js:67:17) | |
at IncomingForm.write (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:137:8) | |
at IncomingMessage.<anonymous> (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:91:12) | |
at IncomingMessage.emit (events.js:81:20) | |
at HTTPParser.onBody (http.js:121:23) | |
at Socket.ondata (http.js:1019:22) | |
at Socket._onReadable (net.js:683:27) | |
at IOWatcher.onReadable [as callback] (net.js:177:10) | |
{ stack: [Getter/Setter], | |
arguments: undefined, | |
type: undefined, | |
message: 'Cannot resume() closed Socket.' } | |
http.js:527 | |
throw new Error("Can't set headers after they are sent."); | |
^ | |
Error: Can't set headers after they are sent. | |
at ServerResponse.<anonymous> (http.js:527:11) | |
at ServerResponse.setHeader (/srv/www/node/ithrowu/node_modules/express/node_modules/connect/lib/patch.js:62:20) | |
at ServerResponse.header (/srv/www/node/ithrowu/node_modules/express/lib/response.js:280:8) | |
at ServerResponse.redirect (/srv/www/node/ithrowu/node_modules/express/lib/response.js:413:10) | |
at /srv/www/node/ithrowu/controllers/throws.js:23:11 | |
at IncomingForm.<anonymous> (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:114:9) | |
at IncomingForm.emit (events.js:81:20) | |
at IncomingForm._error (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:243:8) | |
at IncomingForm.resume (/srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:72:14) | |
at /srv/www/node/ithrowu/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js:199:12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment