Comments (9)
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 [email protected]
and [email protected]
.
Weired
from multer.
@fundon can be merge that pr?
from multer.
I agree 100%
What I did right now is use koa-compose
to combine the multer middlware and a simple middleware that copies ctx.req.files
, ctx.req.body
, & ctx.req.file
to ctx.request
. I know this is not the best way to do it but I can live with it until this is fixed.
from multer.
I have made a pull request that simply exposes the respective objects to Koa's Request wrapper. #15
Additionally updated the test requirements to node 6 or greater as Koa 2.x specifies as its requirement.
Side note: I have tried changing this middleware to pass the ctx.request object to multer, but that failed due to the fact that multer uses the streaming properties (eg: req.pipe(busboy)
) of the native Request object, whereas the Koa wrapper doesn't seem to have that exposed.
from multer.
Upload pictures are binary data, how can I convert the picture file?
from multer.
@QianSu Did you try to change the file extension?
from multer.
@dominhhai Brother, thank you for your advice, I have solved this problem
from multer.
Since pass ctx.req, ctx.next to an express middleware is kind of Hack. Why not delegate
ctx.req.body
/ ctx.req.file
/ ctx.req.files
to ctx.request
but not the reverse 😂
from multer.
Please see my comment at #30 (comment) and close this issue. The official Koa organization has forked this repository and released it (with PR's merged) under @koajs/multer
. Thank you.
from multer.
Related Issues (20)
- How to use with individual routes? HOT 8
- TypeError: fn.apply is not a function HOT 2
- Does this work fine with multer-s3? HOT 1
- Middleware resolves before ctx.requests is populated with uploaded file information
- AssertionError [ERR_ASSERTION]: headers have already been sent HOT 1
- Upgrade multer to latest release 2.x alpha HOT 1
- Why parsed body not available on Koa's supercharged request? HOT 10
- Please add .d.ts file to this project to support typescript HOT 3
- Multer doesn't save an extensionand name of file HOT 1
- How to catch error throw in the middleware? HOT 4
- when directory doesn't exist, how can i create it automatically?
- Upgrade to multer 1.4.0 HOT 2
- The package lacks documentation. HOT 2
- Access to stream underneath HOT 1
- Is this project dead? HOT 3
- 2.0.0 release HOT 6
- Trying out the example gives an error HOT 4
- Koa multer can not work with koa-router HOT 7
- Multer crashes node (Cannot read property 'headers' of undefined) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multer.