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

192
Views
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
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!