File tree Expand file tree Collapse file tree 4 files changed +49
-0
lines changed
Expand file tree Collapse file tree 4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " aws-sdk-js-codemod " : patch
3+ ---
4+
5+ Add transformation for s3 ManagedUploadOptions
Original file line number Diff line number Diff line change 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 ( ) ;
Original file line number Diff line number Diff line change 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 ( ) ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments