@@ -337,6 +337,54 @@ describe 'AWS.S3.ManagedUpload', ->
337
337
expect (data .Bucket ).to .equal (' bucket' )
338
338
done ()
339
339
340
+ describe ' Location' , ->
341
+ it ' returns paths with simple string keys for single part uploads' , (done ) ->
342
+ reqs = helpers .mockResponses [
343
+ data : ETag : ' ETAG'
344
+ ]
345
+ send {Body : smallbody, ContentEncoding : ' encoding' , Key : ' file.ext' }, ->
346
+ expect (err).not .to .exist
347
+ expect (data .Location ).to .equal (' https://bucket.s3.mock-region.amazonaws.com/file.ext' )
348
+ done ()
349
+
350
+ it ' returns paths with simple string keys for multipart uploads' , (done ) ->
351
+ reqs = helpers .mockResponses [
352
+ { data : UploadId : ' uploadId' }
353
+ { data : ETag : ' ETAG1' }
354
+ { data : ETag : ' ETAG2' }
355
+ { data : ETag : ' ETAG3' }
356
+ { data : ETag : ' ETAG4' }
357
+ { data : ETag : ' FINAL_ETAG' , Location : ' https://bucket.s3.mock-region.amazonaws.com/file.ext' }
358
+ ]
359
+ send {Body : bigbody, ContentEncoding : ' encoding' , Key : ' file.ext' }, ->
360
+ expect (err).not .to .exist
361
+ expect (data .Location ).to .equal (' https://bucket.s3.mock-region.amazonaws.com/file.ext' )
362
+ done ()
363
+
364
+ it ' returns paths with subfolder keys for single part uploads' , (done ) ->
365
+ reqs = helpers .mockResponses [
366
+ data : ETag : ' ETAG'
367
+ ]
368
+ send {Body : smallbody, ContentEncoding : ' encoding' , Key : ' directory/subdirectory/file.ext' }, ->
369
+ expect (err).not .to .exist
370
+ expect (data .Location ).to .equal (' https://bucket.s3.mock-region.amazonaws.com/directory/subdirectory/file.ext' )
371
+ done ()
372
+
373
+ it ' returns paths with subfolder keys for multipart uploads' , (done ) ->
374
+ reqs = helpers .mockResponses [
375
+ { data : UploadId : ' uploadId' }
376
+ { data : ETag : ' ETAG1' }
377
+ { data : ETag : ' ETAG2' }
378
+ { data : ETag : ' ETAG3' }
379
+ { data : ETag : ' ETAG4' }
380
+ { data : ETag : ' FINAL_ETAG' , Location : ' https://bucket.s3.mock-region.amazonaws.com/directory%2Fsubdirectory%2Ffile.ext' }
381
+ ]
382
+ send {Body : bigbody, ContentEncoding : ' encoding' , Key : ' folder/file.ext' }, ->
383
+ expect (err).not .to .exist
384
+ expect (data .Location ).to .equal (' https://bucket.s3.mock-region.amazonaws.com/directory/subdirectory/file.ext' )
385
+ done ()
386
+
387
+
340
388
if AWS .util .isNode ()
341
389
describe ' streaming' , ->
342
390
it ' sends a small stream in a single putObject' , (done ) ->
@@ -584,6 +632,7 @@ describe 'AWS.S3.ManagedUpload', ->
584
632
' s3.putObjectTagging'
585
633
]
586
634
expect (err).not .to .exist
635
+ expect (data .Location ).to .equal (' FINAL_LOCATION' )
587
636
expect (reqs[6 ].params .Tagging ).to .deep .equal ({
588
637
TagSet : [
589
638
{Key : ' tag1' , Value : ' value1' }
@@ -593,6 +642,40 @@ describe 'AWS.S3.ManagedUpload', ->
593
642
})
594
643
done ()
595
644
645
+ it ' return errors from PutObjectTagging request following a successful multipart upload with tags' , (done ) ->
646
+ reqs = helpers .mockResponses [
647
+ { data : UploadId : ' uploadId' }
648
+ { data : ETag : ' ETAG1' }
649
+ { data : ETag : ' ETAG2' }
650
+ { data : ETag : ' ETAG3' }
651
+ { data : ETag : ' ETAG4' }
652
+ { data : ETag : ' FINAL_ETAG' , Location : ' FINAL_LOCATION' }
653
+ { error : { code : ' InvalidRequest' }, data : null }
654
+ ]
655
+
656
+ upload = new AWS.S3.ManagedUpload (
657
+ service : s3
658
+ params : {Body : bigbody}
659
+ tags : [
660
+ {Key : ' tag1' , Value : ' value1' }
661
+ {Key : ' tag2' , Value : ' value2' }
662
+ {Key : ' étiquette' , Value : ' valeur à être encodé' }
663
+ ]
664
+ )
665
+
666
+ send {}, ->
667
+ expect (helpers .operationsForRequests (reqs)).to .eql [
668
+ ' s3.createMultipartUpload'
669
+ ' s3.uploadPart'
670
+ ' s3.uploadPart'
671
+ ' s3.uploadPart'
672
+ ' s3.uploadPart'
673
+ ' s3.completeMultipartUpload'
674
+ ' s3.putObjectTagging'
675
+ ]
676
+ expect (err .code ).to .equal (' InvalidRequest' )
677
+ done ()
678
+
596
679
it ' should throw when tags are not provided as an array' , (done ) ->
597
680
reqs = helpers .mockResponses [
598
681
data : ETag : ' ETAG'
0 commit comments