Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda