Skip to content

Commit

Permalink
chore: upgrade to latest connect-busboy (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
redonkulus authored May 23, 2022
1 parent 4b6db05 commit f5936f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ exports.extend = function(app, options) {
};

if (options.upload && allowUpload) {
req.busboy.on('file', (name, file, filename, encoding, mimetype) => {
req.busboy.on('file', (name, file, info) => {
const { filename, encoding, mimeType } = info;
const fileUuid = uuid.v4();
const nameStripped = options.strip(name, 'name');
const filenameStripped = options.strip(filename || /*istanbul ignore next*/ '', 'filename');
const out = path.join(options.path, '/', fileUuid, '/', nameStripped, filenameStripped);

if (mimeTypeLimit && !mimeTypeLimit.some(type => { return type === mimetype; })) {
if (mimeTypeLimit && !mimeTypeLimit.some(type => { return type === mimeType; })) {
return file.resume();
}

Expand All @@ -131,7 +132,7 @@ exports.extend = function(app, options) {
file: out,
filename: filename,
encoding: encoding,
mimetype: mimetype,
mimetype: mimeType,
truncated: false,
done: false
};
Expand All @@ -156,7 +157,7 @@ exports.extend = function(app, options) {
req.busboy.on('field', (name, data) => {
convertParams(req.body, name, data);
});
req.busboy.on('finish', () => {
req.busboy.on('close', () => {
req.body = qs.parse(qs.stringify(req.body), { arrayLimit: options.arrayLimit });
if (restrictMultiple) {
[req.body, req.files].forEach(fixDups);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
},
"homepage": "https://github.com/yahoo/express-busboy",
"dependencies": {
"body": "~5.1.0",
"connect-busboy": "~0.0.1",
"body": "^5.1.0",
"connect-busboy": "^1.0.0",
"mkdirp": "^1.0.4",
"qs": "^6.4.0",
"qs": "^6.10.3",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down

0 comments on commit f5936f8

Please sign in to comment.