Skip to content

Commit 4b17da0

Browse files
authored
Add transformation for s3 ManagedUploadOptions (#439)
1 parent e71f5e6 commit 4b17da0

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

.changeset/smart-birds-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Add transformation for s3 ManagedUploadOptions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import AWS from "aws-sdk";
2+
3+
const client = new AWS.S3({ region: "REGION" });
4+
await client
5+
.upload(
6+
{
7+
Body: "BODY",
8+
Bucket: "Bucket",
9+
ContentType: "ContentType",
10+
Key: "Key",
11+
},
12+
{
13+
partSize: 1024 * 1024 * 5,
14+
queueSize: 1,
15+
leavePartsOnError: true,
16+
tags: [],
17+
}
18+
)
19+
.promise();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Upload } from "@aws-sdk/lib-storage";
2+
import { S3 } from "@aws-sdk/client-s3";
3+
4+
const client = new S3({ region: "REGION" });
5+
await new Upload({
6+
client,
7+
8+
params: {
9+
Body: "BODY",
10+
Bucket: "Bucket",
11+
ContentType: "ContentType",
12+
Key: "Key",
13+
},
14+
15+
partSize: 1024 * 1024 * 5,
16+
queueSize: 1,
17+
leavePartsOnError: true,
18+
tags: []
19+
})
20+
.done();

src/transforms/v2-to-v3/apis/replaceS3UploadApi.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export const replaceS3UploadApi = (
4949
);
5050
}
5151

52+
const options = callExpression.node.arguments[1];
53+
if (options && options.type === "ObjectExpression") {
54+
properties.push(...options.properties);
55+
}
56+
5257
return j.newExpression(j.identifier("Upload"), [j.objectExpression(properties)]);
5358
});
5459

0 commit comments

Comments
 (0)