Created
September 13, 2021 03:18
-
-
Save metaskills/399ec7564057e9221ac4723e93a6eecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { S3, GetObjectCommand } = require("@aws-sdk/client-s3"); | |
const S3C = new S3(S3Config.mms()); | |
response = await S3C.send(new GetObjectCommand(params)); | |
data = await this.streamToString(response.Body); | |
async streamToString(stream) { | |
return new Promise((resolve, reject) => { | |
const chunks = []; | |
stream.on("data", (chunk) => chunks.push(chunk)); | |
stream.on("error", reject); | |
stream.on("end", () => resolve(Buffer.concat(chunks))); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment