@@ -1679,15 +1679,16 @@ function getBucket(params, callback) {
1679
1679
if ( err ) {
1680
1680
return callback ( err ) ;
1681
1681
}
1682
- var contents = data . ListBucketResult . Contents || [ ] ;
1683
- var CommonPrefixes = data . ListBucketResult . CommonPrefixes || [ ] ;
1682
+ var ListBucketResult = data . ListBucketResult || { } ;
1683
+ var Contents = ListBucketResult . Contents || [ ] ;
1684
+ var CommonPrefixes = ListBucketResult . CommonPrefixes || [ ] ;
1684
1685
1685
- contents = util . isArray ( contents ) ? contents : [ contents ] ;
1686
+ Contents = util . isArray ( Contents ) ? Contents : [ Contents ] ;
1686
1687
CommonPrefixes = util . isArray ( CommonPrefixes ) ? CommonPrefixes : [ CommonPrefixes ] ;
1687
1688
1688
- var result = util . clone ( data . ListBucketResult ) ;
1689
+ var result = util . clone ( ListBucketResult ) ;
1689
1690
util . extend ( result , {
1690
- Contents : contents ,
1691
+ Contents : Contents ,
1691
1692
CommonPrefixes : CommonPrefixes ,
1692
1693
statusCode : data . statusCode ,
1693
1694
headers : data . headers
@@ -1747,10 +1748,11 @@ function getBucketAcl(params, callback) {
1747
1748
if ( err ) {
1748
1749
return callback ( err ) ;
1749
1750
}
1750
- var Owner = data . AccessControlPolicy . Owner || { } ;
1751
- var Grant = data . AccessControlPolicy . AccessControlList . Grant || [ ] ;
1751
+ var AccessControlPolicy = data . AccessControlPolicy || { } ;
1752
+ var Owner = AccessControlPolicy . Owner || { } ;
1753
+ var Grant = AccessControlPolicy . AccessControlList . Grant || [ ] ;
1752
1754
Grant = util . isArray ( Grant ) ? Grant : [ Grant ] ;
1753
- var result = decodeAcl ( data . AccessControlPolicy ) ;
1755
+ var result = decodeAcl ( AccessControlPolicy ) ;
1754
1756
if ( data . headers && data . headers [ 'x-cos-acl' ] ) {
1755
1757
result . ACL = data . headers [ 'x-cos-acl' ] ;
1756
1758
}
@@ -2423,12 +2425,13 @@ function listObjectVersions(params, callback) {
2423
2425
if ( err ) {
2424
2426
return callback ( err ) ;
2425
2427
}
2426
- var DeleteMarkers = data . ListVersionsResult . DeleteMarker || [ ] ;
2428
+ var ListVersionsResult = data . ListVersionsResult || { } ;
2429
+ var DeleteMarkers = ListVersionsResult . DeleteMarker || [ ] ;
2427
2430
DeleteMarkers = util . isArray ( DeleteMarkers ) ? DeleteMarkers : [ DeleteMarkers ] ;
2428
- var Versions = data . ListVersionsResult . Version || [ ] ;
2431
+ var Versions = ListVersionsResult . Version || [ ] ;
2429
2432
Versions = util . isArray ( Versions ) ? Versions : [ Versions ] ;
2430
2433
2431
- var result = util . clone ( data . ListVersionsResult ) ;
2434
+ var result = util . clone ( ListVersionsResult ) ;
2432
2435
delete result . DeleteMarker ;
2433
2436
delete result . Version ;
2434
2437
util . extend ( result , {
@@ -2655,10 +2658,11 @@ function getObjectAcl(params, callback) {
2655
2658
if ( err ) {
2656
2659
return callback ( err ) ;
2657
2660
}
2658
- var Owner = data . AccessControlPolicy . Owner || { } ;
2659
- var Grant = data . AccessControlPolicy . AccessControlList . Grant || [ ] ;
2661
+ var AccessControlPolicy = data . AccessControlPolicy || { } ;
2662
+ var Owner = AccessControlPolicy . Owner || { } ;
2663
+ var Grant = AccessControlPolicy . AccessControlList && AccessControlPolicy . AccessControlList . Grant || [ ] ;
2660
2664
Grant = util . isArray ( Grant ) ? Grant : [ Grant ] ;
2661
- var result = decodeAcl ( data . AccessControlPolicy ) ;
2665
+ var result = decodeAcl ( AccessControlPolicy ) ;
2662
2666
if ( data . headers && data . headers [ 'x-cos-acl' ] ) {
2663
2667
result . ACL = data . headers [ 'x-cos-acl' ] ;
2664
2668
}
@@ -2743,7 +2747,7 @@ function optionsObject(params, callback) {
2743
2747
headers : headers
2744
2748
} , function ( err , data ) {
2745
2749
if ( err ) {
2746
- if ( err . statusCode && err . statusCode == 403 ) {
2750
+ if ( err . statusCode && err . statusCode === 403 ) {
2747
2751
return callback ( null , {
2748
2752
OptionsForbidden : true ,
2749
2753
statusCode : err . statusCode
@@ -2804,7 +2808,7 @@ function putObjectCopy(params, callback) {
2804
2808
if ( err ) {
2805
2809
return callback ( err ) ;
2806
2810
}
2807
- var result = util . clone ( data . CopyObjectResult ) ;
2811
+ var result = util . clone ( data . CopyObjectResult || { } ) ;
2808
2812
util . extend ( result , {
2809
2813
statusCode : data . statusCode ,
2810
2814
headers : data . headers
@@ -2827,7 +2831,7 @@ function uploadPartCopy(params, callback) {
2827
2831
if ( err ) {
2828
2832
return callback ( err ) ;
2829
2833
}
2830
- var result = util . clone ( data . CopyObjectResult ) ;
2834
+ var result = util . clone ( data . CopyObjectResult || { } ) ;
2831
2835
util . extend ( result , {
2832
2836
statusCode : data . statusCode ,
2833
2837
headers : data . headers
@@ -2857,13 +2861,14 @@ function deleteMultipleObject(params, callback) {
2857
2861
if ( err ) {
2858
2862
return callback ( err ) ;
2859
2863
}
2860
- var Deleted = data . DeleteResult . Deleted || [ ] ;
2861
- var Errors = data . DeleteResult . Error || [ ] ;
2864
+ var DeleteResult = data . DeleteResult || { } ;
2865
+ var Deleted = DeleteResult . Deleted || [ ] ;
2866
+ var Errors = DeleteResult . Error || [ ] ;
2862
2867
2863
2868
Deleted = util . isArray ( Deleted ) ? Deleted : [ Deleted ] ;
2864
2869
Errors = util . isArray ( Errors ) ? Errors : [ Errors ] ;
2865
2870
2866
- var result = util . clone ( data . DeleteResult ) ;
2871
+ var result = util . clone ( DeleteResult ) ;
2867
2872
util . extend ( result , {
2868
2873
Error : Errors ,
2869
2874
Deleted : Deleted ,
@@ -3050,7 +3055,8 @@ function multipartComplete(params, callback) {
3050
3055
object : params . Key ,
3051
3056
isLocation : true
3052
3057
} ) ;
3053
- var result = util . extend ( data . CompleteMultipartUploadResult , {
3058
+ var CompleteMultipartUploadResult = data . CompleteMultipartUploadResult || { } ;
3059
+ var result = util . extend ( CompleteMultipartUploadResult , {
3054
3060
Location : url ,
3055
3061
statusCode : data . statusCode ,
3056
3062
headers : data . headers
@@ -3111,7 +3117,7 @@ function multipartList(params, callback) {
3111
3117
data . ListMultipartUploadsResult . Upload = Upload ;
3112
3118
data . ListMultipartUploadsResult . CommonPrefixes = CommonPrefixes ;
3113
3119
}
3114
- var result = util . clone ( data . ListMultipartUploadsResult ) ;
3120
+ var result = util . clone ( data . ListMultipartUploadsResult || { } ) ;
3115
3121
util . extend ( result , {
3116
3122
statusCode : data . statusCode ,
3117
3123
headers : data . headers
@@ -3154,11 +3160,12 @@ function multipartListPart(params, callback) {
3154
3160
if ( err ) {
3155
3161
return callback ( err ) ;
3156
3162
}
3157
- var Part = data . ListPartsResult . Part || [ ] ;
3163
+ var ListPartsResult = data . ListPartsResult || { } ;
3164
+ var Part = ListPartsResult . Part || [ ] ;
3158
3165
Part = util . isArray ( Part ) ? Part : [ Part ] ;
3159
3166
3160
- data . ListPartsResult . Part = Part ;
3161
- var result = util . clone ( data . ListPartsResult ) ;
3167
+ ListPartsResult . Part = Part ;
3168
+ var result = util . clone ( ListPartsResult ) ;
3162
3169
util . extend ( result , {
3163
3170
statusCode : data . statusCode ,
3164
3171
headers : data . headers
0 commit comments