Skip to content

how to use Koa-multer and Koa-router as service object in feathersjs? #3184

Answered by SYBIOTE
SYBIOTE asked this question in Q&A
Discussion options

You must be logged in to vote

i cant seem to find a way to use koa-router , but you can use before: service middle wate with koa multer instead
example snippet

import Multer from 'koa-multer'
const multipartMiddleware = Multer({ limits: { fieldSize: Infinity, files: 1 } })
// other code
app.use(
 'upload',
 {
  create: upload(app)
 },
 {
 koa: {
 before: [
    multipartMiddleware.any(),
    async (ctx, next) => {
    console.log('trying to upload file')
    // handle as needed
    await next()
    console.log('uploaded file')
    return ctx.body
  }
  ]
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vicentecastroa
Comment options

Answer selected by SYBIOTE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants