-
Notifications
You must be signed in to change notification settings - Fork 640
Description
Describe the bug
I'm using the GetObjectCommand with an S3Client to pull a file down from S3. In v2 of the SDK I can write response.Body.toString('utf-8') to turn the response into a string. In v3 of the SDK response.Body is a complex object that does not seem to expose the result of reading from the socket.
It's not clear if the SDK's current behaviour is intentional, but the change in behaviour since v2 is significant and undocumented.
SDK version number
3.1.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
v12.18.0
To Reproduce (observed behavior)
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
export async function getFile() {
const client = new S3Client({ region: 'eu-west-1' });
const cmd = new GetObjectCommand({
Bucket: 'my-bucket',
Key: '/readme.txt',
});
const data = await client.send(cmd);
console.log(data.Body.toString('utf-8'));
}Expected behavior
It should print the text of the file.
Additional context
data.Body is a complex object with circular references. Object.keys(data.Body) returns the following:
[
"_readableState",
"readable",
"_events",
"_eventsCount",
"_maxListeners",
"socket",
"connection",
"httpVersionMajor",
"httpVersionMinor",
"httpVersion",
"complete",
"headers",
"rawHeaders",
"trailers",
"rawTrailers",
"aborted",
"upgrade",
"url",
"method",
"statusCode",
"statusMessage",
"client",
"_consuming",
"_dumped",
"req"
]