File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
__tests__/providers/s3/apis/uploadData
src/providers/s3/apis/uploadData Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,22 @@ describe('uploadData with path', () => {
180180 } ,
181181 ) ;
182182
183+ it ( 'should use putObject for 0 bytes data (e.g. create a folder)' , ( ) => {
184+ const testInput = {
185+ path : 'test-path' ,
186+ data : '' , // 0 bytes
187+ } ;
188+
189+ uploadData ( testInput ) ;
190+
191+ expect ( mockPutObjectJob ) . toHaveBeenCalledWith (
192+ testInput ,
193+ expect . any ( AbortSignal ) ,
194+ expect . any ( Number ) ,
195+ ) ;
196+ expect ( mockGetMultipartUploadHandlers ) . not . toHaveBeenCalled ( ) ;
197+ } ) ;
198+
183199 it ( 'should use uploadTask' , async ( ) => {
184200 mockPutObjectJob . mockReturnValueOnce ( 'putObjectJob' ) ;
185201 mockCreateUploadTask . mockReturnValueOnce ( 'uploadTask' ) ;
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ export function uploadData(input: UploadDataInput | UploadDataWithPathInput) {
135135 StorageValidationErrorCode . ObjectIsTooLarge ,
136136 ) ;
137137
138- if ( dataByteLength && dataByteLength <= DEFAULT_PART_SIZE ) {
138+ if ( dataByteLength !== undefined && dataByteLength <= DEFAULT_PART_SIZE ) {
139139 // Single part upload
140140 const abortController = new AbortController ( ) ;
141141
You can’t perform that action at this time.
0 commit comments