Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Koa Multer doesn't work with POST only GET endpoints

I'm trying to upload a file using @koa/multer and js according to the library documentation, but it only works on GET endpoints and if I try to replicate the same thing in POST enpoints the file property is undefined. Does anyone know how to fix it?

ROUTER.js

import Router from 'koa-router';
import Multer from '@koa/multer';

const router = new Router();
const upload = multer();

router.post('/test', upload.single('csv'), Controller.test) //if change to GET works fine!!
module.exports = router;

CONTROLLER.js

  async test(ctx) {
    console.log(ctx.request.file); //undefined
    console.log(ctx.file); //undefined
    console.log(ctx.request.body); //undefined
  
    ctx.response.status = 204;
  }

if router is get the console.logs return

{
  fieldname: 'csv',
  originalname: 'namefile.csv',
  encoding: '7bit',
  mimetype: 'text/csv',
  buffer: <Buffer 41 63 63 65 73 43 55 4d 51 45 53 4b 53 47 51 4b 45 ... 46 more bytes>,
  size: 96
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!