File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -862,6 +862,23 @@ describe(Upload.name, () => {
862862 } ) . toThrow ( `The byte size for part number 1, size 0 does not match expected size ${ MOCK_PART_SIZE } ` ) ;
863863 } ) ;
864864
865+ it ( "should use the user-specified partSize when provided, taking precedence over calculated partSize" , ( ) => {
866+ const bigBuffer = Buffer . alloc ( 10 ) ;
867+ const customPartSize = 50 * 1024 * 1024 ; // 50 MB
868+
869+ const upload = new Upload ( {
870+ params : {
871+ Key : "big-file" ,
872+ Bucket : "bucket" ,
873+ Body : bigBuffer ,
874+ } ,
875+ partSize : customPartSize ,
876+ client : new S3 ( { } ) ,
877+ } ) ;
878+
879+ expect ( ( upload as any ) . partSize ) . toBe ( customPartSize ) ;
880+ } ) ;
881+
865882 it ( "should skip validation for single-part uploads" , ( ) => {
866883 const upload = new Upload ( {
867884 params,
Original file line number Diff line number Diff line change @@ -93,7 +93,8 @@ export class Upload extends EventEmitter {
9393 this . bytesUploadedSoFar = 0 ;
9494 this . abortController = options . abortController ?? new AbortController ( ) ;
9595
96- this . partSize = Math . max ( Upload . MIN_PART_SIZE , Math . floor ( ( this . totalBytes || 0 ) / this . MAX_PARTS ) ) ;
96+ this . partSize =
97+ options . partSize || Math . max ( Upload . MIN_PART_SIZE , Math . floor ( ( this . totalBytes || 0 ) / this . MAX_PARTS ) ) ;
9798 this . expectedPartsCount = this . totalBytes !== undefined ? Math . ceil ( this . totalBytes / this . partSize ) : undefined ;
9899
99100 this . __validateInput ( ) ;
You can’t perform that action at this time.
0 commit comments