createReadStream()
behavior replication in v3
#5167
Answered
by
yenfryherrerafeliz
jirimoravcik
asked this question in
Q&A
-
In SDK v2, one could do: const docClient = new aws.DynamoDB.DocumentClient(...);
const stream = docClient.query(queryParams).createReadStream(); How to replicate this behavior in v3? |
Beta Was this translation helpful? Give feedback.
Answered by
yenfryherrerafeliz
Sep 13, 2023
Replies: 2 comments
-
Hi @jirimoravcik, to accomplish this with v3 you would need to add a middleware to the client as follow: import {DynamoDBClient} from "@aws-sdk/client-dynamodb";
import {DynamoDBDocumentClient} from "@aws-sdk/lib-dynamodb";
const client = new DynamoDBClient({region: "us-east-2"});
client.middlewareStack.addRelativeTo(
(next) => async (args) => {
const { response } = await next(args);
const readableStream = response.body; // HERE IS YOUR READABLE STREAM
return {
response,
};
},
{
name: "customResponseBodyMiddleware",
toMiddleware: "deserializerMiddleware",
relation: "after",
step: "deserialize",
override: true,
}
);
const documentClient = DynamoDBDocumentClient.from(client); Please let me know if that helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RanVaknin
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @jirimoravcik, to accomplish this with v3 you would need to add a middleware to the client as follow: