question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

multer is writing to `ctx.req` instead of `ctx.request`

See original GitHub issue

I think multer should write to ctx.request because that is the koa request object currently it is writing to the ctx.req which is the original node request object.

In my opinion this change would align the behaviour of this module with the koa ecosystem.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
raphaelsoulcommented, Apr 5, 2017

on my side, those below are always undefined:

  • ctx.request.files
  • ctx.request.file
  • ctx.req.file
  • ctx.req.files

the configuration like this:

import multer from 'koa-multer'
import bodyparser from 'koa-bodyparser'
const upload = multer({ dest: '/path/to/tmp' })

//use it globally
app.use(multer.any())
app.use(bodyparser())

I tried postman and html form with enctype="multipart/form-data", both had saved file with hashed name but I can’t access to file infomation via ctx

the version is koa-multer@1.0.1 and koa@2.2.0.

Weired

6reactions
i5tingcommented, May 16, 2017

@fundon can be merge that pr?

Read more comments on GitHub >

github_iconTop Results From Across the Web

2.0.0 release · Issue #30 · koa-modules/multer - GitHub
If I am granted npm/GitHub access, here are my plans for 2.0.0 release: expose ctx.file, ctx.files, ctx.request.file, and ctx.request.files ...
Read more >
when I try to upload images koa2 ctx.req.files = [] but ctx ...
it s true that ctx.request.files and ctx.req.files get different results. It s like the koa-multer using ctx.req.files to handle file type.
Read more >
r/node - Reddit
Writing a simple POSTed text file with node.js/Koa ... writeFile((outdir + sanitized), ctx.request.body, function(err) { if(err) return ...
Read more >
Get Started with Koa.js for Node Applications | Okta Developer
Koa.js is a modern server framework from the creators of Express. Learn how to get started with Koa.js by building a fun facial...
Read more >
parse-request - npm
This package exports a function that accepts an Object options argument: options (Object) - a configuration object. req (Object) - an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found