-
Notifications
You must be signed in to change notification settings - Fork 584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3 GetObject returns a stream body #6707
Comments
The linked page states the return type of the body in S3 GetObject is a stream in the section "Example Syntax" and in the section "GetObjectCommand Output". Also take a look at https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/javascript_s3_code_examples.html#basics. As part of #6691, we will be creating additional documentation for streaming operations. |
There is nothing readable in there, I am not a beginner programmer and the usage example isn't a real code example... Just a bunch of convoluted text with no meaning. Every other Nodejs SDK out there shows you how to implement, but Amazon is way above that. ---------------------------------ACTUAL CODE EXAMPLE---------------------------------------------
} catch (error) {
|
Using the example from https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/javascript_s3_code_examples.html#basics, you do not need to concatenate into a buffer yourself. import {
GetObjectCommand,
S3Client,
} from "@aws-sdk/client-s3";
const response = await client.send(
new GetObjectCommand({
Bucket: bucketName,
Key: key,
}),
);
const str = await response.Body.transformToString();
console.log(str); // a string. Alternatively, a byte array // Uint8Array, which can be converted to Buffer.
const bytes = await response.Body.transformToByteArray(); |
Currently, the developer guide linked above contains more practical examples than the auto-generated API shape documentation you have seen. We plan to integrate this example into the API docs in a future update. |
Hello, thank you and sorry for my previous comments, the "const str = await
response.Body.transformToString();" works very well and I'm able to get the
body of my s3 files.
Thank you once again!
…On Tue, 3 Dec 2024 at 20:47, George Fu ***@***.***> wrote:
Currently, the developer guide linked above contains more practical
examples than the auto-generated API shape documentation you have seen.
We plan to integrate this example into the API docs in a future update.
—
Reply to this email directly, view it on GitHub
<#6707 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANYX4KEGO5VYWXWVVH4RVJL2DX4E5AVCNFSM6AAAAABS34L7FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJVGMZTENZYHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hello, thank you and sorry for my previous comments, the "const byteArray =
await response.Body.transformToString();" works very well and I'm able to
get the body of my s3 files.
Thank you once again!
…On Wed, 4 Dec 2024 at 04:07, LiviuBranea ***@***.***> wrote:
Hello, thank you and sorry for my previous comments, the "const str =
await response.Body.transformToString();" works very well and I'm able to
get the body of my s3 files.
Thank you once again!
On Tue, 3 Dec 2024 at 20:47, George Fu ***@***.***> wrote:
> Currently, the developer guide linked above contains more practical
> examples than the auto-generated API shape documentation you have seen.
>
> We plan to integrate this example into the API docs in a future update.
>
> —
> Reply to this email directly, view it on GitHub
> <#6707 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ANYX4KEGO5VYWXWVVH4RVJL2DX4E5AVCNFSM6AAAAABS34L7FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJVGMZTENZYHE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Describe the issue
This documentation is absolutely deplorable, without chatGPT I would've been unable to use S3. Literally not one word about 'getObjectCommand' returning data in streams and you having to handle the chunks with a promise. All I wanted to do was to upload an image from a nodeJs server and then read it from S3. Of course, this simple task took me several hours because getting the body from an S3 file is apparently a herculean task
Links
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/command/GetObjectCommand/
The text was updated successfully, but these errors were encountered: