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

173
Visualizações
Is there a way to put Express.Multer.File into a FormData object?

I'm need help on finding how to put a file with a type Express.Multer.File into a FormData object.

Context: I'm receiving a file with a type Express.Multer.File (I'm using nestjs, so I used this part of the documentation : https://docs.nestjs.com/techniques/file-upload) that I need to put in a FormData, to send it to another API.

I tried form.append('randomword', file); but I get the following error :

TypeError: source.on is not a function
    at Function.DelayedStream.create (xxx/delayed-stream/lib/delayed_stream.js:33:10)
    at FormData.CombinedStream.append (xxx/combined-stream/lib/combined_stream.js:45:37)
...

I clearly sense that I'm doing it the wrong way, but I'm kinda lost on how to achieve something like this.

Could someone help me please ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I found out a "workaround" for this method.

  • First, I get the file with the type Express.Multer.File.
  • Then I save it using createWriteStream from fs.
  • Finally, I pass it into the FormData object using createReadStream.

And done ! It isn't the best way to do this, but kind of a workaround, though.

about 4 years ago · Juan Pablo Isaza Relatório
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