Skip to content

Commit

Permalink
Fix breaking changes with new busboy version
Browse files Browse the repository at this point in the history
- No more constructor
- Truncated flags, encoding, and mime type information have been consolidated
into a single object passed to the event handlers
See: mscdex/busboy#266
  • Loading branch information
ostec-mh committed Aug 9, 2022
1 parent b5ba5d1 commit 6a8ac73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions extract.js
Expand Up @@ -8,8 +8,9 @@ module.exports = function (req, dest, fnDestFilename, opts = {}) {
let files = []
let fields = {}

let busboy = new Busboy(Object.assign({}, opts, {headers: req.headers}))
busboy.on('file', (fieldname, fileStream, filename, encoding, mimetype) => {
let busboy = Busboy(Object.assign({}, opts, {headers: req.headers}))
busboy.on('file', (fieldname, fileStream, info) => {
const { filename, encoding, mimeType } = info;
if (!filename) return fileStream.resume()

files.push(new Promise(function (resolve, reject) {
Expand All @@ -23,7 +24,7 @@ module.exports = function (req, dest, fnDestFilename, opts = {}) {
rs.fieldname = fieldname
rs.filename = filename
rs.encoding = encoding
rs.mimetype = mimetype
rs.mimetype = mimeType

resolve(rs)
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -26,6 +26,6 @@
},
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^0.2.14"
"busboy": "^1.6"
}
}

0 comments on commit 6a8ac73

Please sign in to comment.