File tree Expand file tree Collapse file tree 4 files changed +60
-1
lines changed Expand file tree Collapse file tree 4 files changed +60
-1
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ preset : "ts-jest" ,
3
+ testMatch : [ "**/*.e2e.spec.ts" ] ,
4
+ bail : true ,
5
+ } ;
Original file line number Diff line number Diff line change 14
14
"build:types:downlevel" : " downlevel-dts dist-types dist-types/ts3.4" ,
15
15
"clean" : " rimraf ./dist-* && rimraf *.tsbuildinfo" ,
16
16
"extract:docs" : " api-extractor run --local" ,
17
- "test" : " jest"
17
+ "test" : " jest" ,
18
+ "test:e2e" : " jest -c jest.config.e2e.js"
18
19
},
19
20
"engines" : {
20
21
"node" : " >=14.0.0"
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export async function* getChunkStream<T>(
37
37
partNumber += 1 ;
38
38
}
39
39
}
40
+
40
41
yield {
41
42
partNumber,
42
43
data : currentBuffer . chunks . length !== 1 ? Buffer . concat ( currentBuffer . chunks ) : currentBuffer . chunks [ 0 ] ,
Original file line number Diff line number Diff line change
1
+ import { S3 } from "@aws-sdk/client-s3" ;
2
+ import { Upload } from "@aws-sdk/lib-storage" ;
3
+ import type { AwsCredentialIdentity } from "@smithy/types" ;
4
+ import { randomBytes } from "crypto" ;
5
+ import { Readable } from "stream" ;
6
+
7
+ const region : string | undefined = process ?. env ?. AWS_SMOKE_TEST_REGION ;
8
+ const credentials : AwsCredentialIdentity | undefined = ( globalThis as any ) . credentials || undefined ;
9
+ const Bucket = process ?. env ?. AWS_SMOKE_TEST_BUCKET ;
10
+
11
+ jest . setTimeout ( 45_000 ) ;
12
+
13
+ describe ( "@aws-sdk/lib-storage" , ( ) => {
14
+ let Key = `` ;
15
+ const data = randomBytes ( 20_240_000 ) ;
16
+ const dataString = data . toString ( ) ;
17
+
18
+ const client = new S3 ( {
19
+ region,
20
+ credentials,
21
+ } ) ;
22
+
23
+ describe ( "Upload" , ( ) => {
24
+ beforeAll ( ( ) => {
25
+ Key = `multi-part-file-${ Date . now ( ) } ` ;
26
+ } ) ;
27
+ afterAll ( async ( ) => {
28
+ await client . deleteObject ( { Bucket, Key } ) ;
29
+ } ) ;
30
+
31
+ for ( const body of [ data , dataString , Readable . from ( data ) ] ) {
32
+ it ( "should upload in parts for input type " + body . constructor . name , async ( ) => {
33
+ const s3Upload = new Upload ( {
34
+ client,
35
+ params : {
36
+ Bucket,
37
+ Key,
38
+ Body : body ,
39
+ } ,
40
+ } ) ;
41
+ await s3Upload . done ( ) ;
42
+
43
+ const object = await client . getObject ( {
44
+ Bucket,
45
+ Key,
46
+ } ) ;
47
+
48
+ expect ( await object . Body ?. transformToString ( ) ) . toEqual ( dataString ) ;
49
+ } ) ;
50
+ }
51
+ } ) ;
52
+ } ) ;
You can’t perform that action at this time.
0 commit comments