Doesn't compatible with multer
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 267
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
Please fix.
The file uploaded with multer has the following json object:
{ fieldname: 'avatar_image',
originalname: 'blob',
name: '1897942a7e194802e27db8e71c7a0fd4',
encoding: '7bit',
mimetype: 'image/jpeg',
path: '/var/folders/m8/x6wjwggd7sl4qv01sb_1r6gc0000gr/T/1897942a7e194802e27db8e71c7a0fd4',
extension: '',
size: 12934,
truncated: false,
buffer: null }
The object is different from the old express file upload.
Here is the error:
/Users/endaxue/workspace/profile/node_modules/imager/lib/imager.js:843
return (file['type'] || file['mimetype']) || file.headers['content-type'];
^
TypeError: Cannot read property 'content-type' of undefined
at getFileType (/Users/endaxue/workspace/profile/node_modules/imager/lib/imager.js:843:60)
at prepare (/Users/endaxue/workspace/profile/node_modules/imager/lib/imager.js:122:18)
at /Users/endaxue/workspace/profile/node_modules/imager/node_modules/async/lib/async.js:111:13
at Array.forEach (native)
at _each (/Users/endaxue/workspace/profile/node_modules/imager/node_modules/async/lib/async.js:32:24)
at Object.async.each (/Users/endaxue/workspace/profile/node_modules/imager/node_modules/async/lib/async.js:110:9)
at /Users/endaxue/workspace/profile/node_modules/imager/lib/imager.js:134:13
at /Users/endaxue/workspace/profile/node_modules/imager/node_modules/async/lib/async.js:232:13
at /Users/endaxue/workspace/profile/node_modules/imager/node_modules/async/lib/async.js:119:25
at /Users/endaxue/workspace/profile/node_modules/imager/node_modules/async/lib/async.js:24:16
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/imager.js at getFileType around line 843, then follow its call from prepare. Compare the multer file object shown in the issue with the fields this entry point reads, and verify that processing a multer upload no longer raises the undefined headers error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100