|
3 | 3 | 
|
4 | 4 | [](https://codecov.io/gh/aws/aws-sdk-js-v3)
|
5 | 5 | [](https://github.com/prettier/prettier)
|
6 |
| -[](https://dependabot.com) |
7 | 6 |
|
8 | 7 | The **AWS SDK for JavaScript v3** is a rewrite of v2 with some great new features.
|
9 | 8 | As with version 2, it enables you to easily work with [Amazon Web Services](https://aws.amazon.com/),
|
@@ -37,6 +36,7 @@ visit our [code samples repo](https://github.com/aws-samples/aws-sdk-js-tests).
|
37 | 36 | 1. [How to upgrade](#other-changes)
|
38 | 37 | 1. [High Level Concepts in V3](#high-level-concepts)
|
39 | 38 | 1. [Generated Packages](#generated-code)
|
| 39 | + 1. [Streams](#streams) |
40 | 40 | 1. [Paginators](#paginators)
|
41 | 41 | 1. [Abort Controller](#abort-controller)
|
42 | 42 | 1. [Middleware Stack](#middleware-stack)
|
@@ -282,6 +282,46 @@ Lastly we have higher level libraries in `/lib`. These are javascript specific l
|
282 | 282 | 1. `/clients`. This sub directory is code generated and depends on code published from `/packages` . It is 1:1 with AWS services and operations. Manual edits should generally not occur here. These are published to NPM under `@aws-sdk/client-XXXX`.
|
283 | 283 | 1. `/lib`. This sub directory depends on generated code published from `/clients`. It wraps existing AWS services and operations to make them easier to work with in Javascript. These are published to NPM under `@aws-sdk/lib-XXXX`
|
284 | 284 |
|
| 285 | +### Streams |
| 286 | + |
| 287 | +Certain command outputs include streams, which have different implementations in |
| 288 | +Node.js and browsers. For convenience, a set of stream handling methods will be |
| 289 | +merged (`Object.assign`) to the output stream object, as defined in |
| 290 | +[SdkStreamMixin](serde-code-url). |
| 291 | + |
| 292 | +Output types having this feature will be indicated by the `WithSdkStreamMixin<T, StreamKey>` |
| 293 | +[wrapper type](serde-code-url), where `T` is the original output type |
| 294 | +and `StreamKey` is the output property key having a stream type specific to |
| 295 | +the runtime environment. |
| 296 | + |
| 297 | +[serde-code-url]: https://github.com/aws/aws-sdk-js-v3/blob/main/packages/types/src/serde.ts |
| 298 | + |
| 299 | +Here is an example using `S3::GetObject`. |
| 300 | + |
| 301 | +```js |
| 302 | +import { S3 } from "@aws-sdk/client-s3"; |
| 303 | + |
| 304 | +const client = new S3({}); |
| 305 | + |
| 306 | +const getObjectResult = await client.getObject({ |
| 307 | + Bucket: "...", |
| 308 | + Key: "...", |
| 309 | +}); |
| 310 | + |
| 311 | +// env-specific stream with added mixin methods. |
| 312 | +const bodyStream = getObjectResult.Body; |
| 313 | + |
| 314 | +// one-time transform. |
| 315 | +const bodyAsString = await bodyStream.transformToString(); |
| 316 | + |
| 317 | +// throws an error on 2nd call, stream cannot be rewound. |
| 318 | +const __error__ = await bodyStream.transformToString(); |
| 319 | +``` |
| 320 | + |
| 321 | +Note that these methods will read the stream in order to collect it, |
| 322 | +so **you must save the output**. The methods cannot be called more than once |
| 323 | +on a stream. |
| 324 | + |
285 | 325 | ### Paginators
|
286 | 326 |
|
287 | 327 | Many AWS operations return paginated results when the response object is too large to return in a single response. In AWS SDK for JavaScript v2, the response contains a token you can use to retrieve the next page of results. You then need to write additional functions to process pages of results.
|
|
0 commit comments