Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda