What is the difference between `getObject` and `createReadStream` in Node.js for S3?

Responsive Ad Header

Question

Grade: Education Subject: Support
What is the difference between `getObject` and `createReadStream` in Node.js for S3?
Asked by:
84 Viewed 84 Answers

Answer (84)

Best Answer
(459)
The `getObject` method in the AWS SDK for JavaScript retrieves the entire object into memory as a Buffer or a stream depending on how it's configured. `createReadStream`, on the other hand, is a method available on the `Body` property of the S3 `getObject` response. It allows you to consume the object as a readable stream, which is more memory-efficient for large files as it processes data in chunks rather than loading the entire file into memory at once.