File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -296,6 +296,22 @@ describe(Upload.name, () => {
296
296
expect ( result . Location ) . toEqual ( "https://s3.region.amazonaws.com/example-bucket/example-key" ) ;
297
297
} ) ;
298
298
299
+ it ( "should return a Location field with decoded slash symbols" , async ( ) => {
300
+ const partSize = 1024 * 1024 * 5 ;
301
+ const largeBuffer = Buffer . from ( "#" . repeat ( partSize + 10 ) ) ;
302
+ const actionParams = { ...params , Body : largeBuffer } ;
303
+ const completeMultipartMockWithLocation = completeMultipartMock . mockResolvedValueOnce ( {
304
+ Location : "https://example-bucket.example-host.com/folder%2Fexample-key" ,
305
+ } ) ;
306
+ const upload = new Upload ( {
307
+ params : actionParams ,
308
+ client : new S3 ( { } ) ,
309
+ } ) ;
310
+ const result = ( await upload . done ( ) ) as CompleteMultipartUploadCommandOutput ;
311
+ expect ( completeMultipartMockWithLocation ) . toHaveBeenCalledTimes ( 1 ) ;
312
+ expect ( result . Location ) . toEqual ( "https://example-bucket.example-host.com/folder/example-key" ) ;
313
+ } ) ;
314
+
299
315
it ( "should upload using multi-part when parts are larger than part size" , async ( ) => {
300
316
// create a string that's larger than 5MB.
301
317
const partSize = 1024 * 1024 * 5 ;
Original file line number Diff line number Diff line change @@ -334,6 +334,9 @@ export class Upload extends EventEmitter {
334
334
} ,
335
335
} ;
336
336
result = await this . client . send ( new CompleteMultipartUploadCommand ( uploadCompleteParams ) ) ;
337
+ if ( typeof result ?. Location === "string" && result . Location . includes ( "%2F" ) ) {
338
+ result . Location = result . Location . replace ( / % 2 F / g, "/" ) ;
339
+ }
337
340
} else {
338
341
result = this . singleUploadResult ! ;
339
342
}
You can’t perform that action at this time.
0 commit comments