File tree Expand file tree Collapse file tree 4 files changed +58
-1
lines changed Expand file tree Collapse file tree 4 files changed +58
-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
+ describe ( "@aws-sdk/lib-storage" , ( ) => {
12
+ let Key = `` ;
13
+ const data = randomBytes ( 20_240_000 ) ;
14
+ const dataString = data . toString ( ) ;
15
+
16
+ const client = new S3 ( {
17
+ region,
18
+ credentials,
19
+ } ) ;
20
+
21
+ describe ( "Upload" , ( ) => {
22
+ beforeAll ( ( ) => {
23
+ Key = `multi-part-file-${ Date . now ( ) } ` ;
24
+ } ) ;
25
+ afterAll ( async ( ) => {
26
+ await client . deleteObject ( { Bucket, Key } ) ;
27
+ } ) ;
28
+
29
+ for ( const body of [ data , dataString , Readable . from ( data ) ] ) {
30
+ it ( "should upload in parts for input type " + body . constructor . name , async ( ) => {
31
+ const s3Upload = new Upload ( {
32
+ client,
33
+ params : {
34
+ Bucket,
35
+ Key,
36
+ Body : body ,
37
+ } ,
38
+ } ) ;
39
+ await s3Upload . done ( ) ;
40
+
41
+ const object = await client . getObject ( {
42
+ Bucket,
43
+ Key,
44
+ } ) ;
45
+
46
+ expect ( await object . Body ?. transformToString ( ) ) . toEqual ( dataString ) ;
47
+ } ) ;
48
+ }
49
+ } ) ;
50
+ } ) ;
You can’t perform that action at this time.
0 commit comments