0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Update busboy to v0.2.3

This commit is contained in:
Brian White 2014-03-01 20:37:15 -05:00
parent b84c8a4726
commit a2074d310c
2 changed files with 12 additions and 17 deletions

View file

@ -9,11 +9,10 @@ var BusBoy = require('busboy'),
function ghostBusBoy(req, res, next) {
var busboy,
stream,
tmpDir,
hasError = false;
tmpDir;
// busboy is only used for POST requests
if (req.method && !req.method.match(/post/i)) {
if (req.method && !/post/i.test(req.method)) {
return next();
}
@ -28,13 +27,9 @@ function ghostBusBoy(req, res, next) {
tmpFileName,
md5 = crypto.createHash('md5');
// If the filename is invalid, mark an error
// If the filename is invalid, skip the stream
if (!filename) {
hasError = true;
}
// If we've flagged any errors, do not process any streams
if (hasError) {
return file.emit('end');
return file.resume();
}
// Create an MD5 hash of original filename
@ -53,12 +48,7 @@ function ghostBusBoy(req, res, next) {
};
});
busboy.on('limit', function () {
hasError = true;
res.send(413, {code: 413, message: 'File size limit breached.'});
});
busboy.on('error', function (error) {
file.on('error', function (error) {
console.log('Error', 'Something went wrong uploading the file', error);
});
@ -72,11 +62,16 @@ function ghostBusBoy(req, res, next) {
});
busboy.on('error', function (error) {
console.log('Error', 'Something went wrong parsing the form', error);
res.send(500, {code: 500, message: 'Could not parse upload completely.'});
});
busboy.on('field', function (fieldname, val) {
req.body[fieldname] = val;
});
busboy.on('end', function () {
busboy.on('finish', function () {
next();
});

View file

@ -33,7 +33,7 @@
"dependencies": {
"bcryptjs": "0.7.10",
"bookshelf": "0.6.1",
"busboy": "0.0.12",
"busboy": "0.2.3",
"colors": "0.6.2",
"connect-slashes": "1.2.0",
"downsize": "0.0.5",