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

194
Visualizações
How to to store the ReadableStream of a PDF file to disk using the AWS SDK V3 version for JavaScript

I am trying to download a PDF file from S3 using AWS SDK for JavaScript V3('aws-sdk/client-s3') in Node JS. It works fine for plain text files but not sure how PDF stream to PDF file. Appreciate any help

I wrote a sample Node JS modules and s3Module.js returns the ReadableStream from the getObject call from AWS. I tried different ways to download the file but the PDF is generated with zero bytes. The Body of the response is visible in the VSCode. I think I am missing encoding or something. Appreciate any help.

s3Module.js

const response = await s3.send(new GetObjectCommand({Bucket:'bucket',Key:'key'});
console.log(response) //print whole ReadableStream
const body = response.Body;
body.pipe(fs.createWriteStream("Test.PDF")) //There was an error opening this document. The file is damaged and could not be repaired.
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