@@ -5,7 +5,7 @@ const https = require('https');
5
5
const logger = require ( '../utilities/logger' ) ;
6
6
7
7
function _createBucketWithNFSEnabled ( host , port , bucketName , accessKey ,
8
- secretKey , verbose , ssl ) {
8
+ secretKey , verbose , ssl , locationConstraint ) {
9
9
const options = {
10
10
host,
11
11
port,
@@ -46,6 +46,13 @@ function _createBucketWithNFSEnabled(host, port, bucketName, accessKey,
46
46
if ( verbose ) {
47
47
logger . info ( 'request headers' , { headers : request . _headers } ) ;
48
48
}
49
+ if ( locationConstraint ) {
50
+ const createBucketConfiguration = '<CreateBucketConfiguration ' +
51
+ 'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' +
52
+ `<LocationConstraint>${ locationConstraint } </LocationConstraint>` +
53
+ '</CreateBucketConfiguration >' ;
54
+ request . write ( createBucketConfiguration ) ;
55
+ }
49
56
request . end ( ) ;
50
57
}
51
58
@@ -66,18 +73,20 @@ function createBucketWithNFSEnabled() {
66
73
. option ( '-p, --port <port>' , 'Port of the server' )
67
74
. option ( '-s' , '--ssl' , 'Enable ssl' )
68
75
. option ( '-v, --verbose' )
76
+ . option ( '-l, --location-constraint <locationConstraint>' ,
77
+ 'location Constraint' )
69
78
. parse ( process . argv ) ;
70
79
71
80
const { host, port, accessKey, secretKey, bucket, verbose,
72
- ssl } = commander ;
81
+ ssl, locationConstraint } = commander ;
73
82
74
83
if ( ! host || ! port || ! accessKey || ! secretKey || ! bucket ) {
75
84
logger . error ( 'missing parameter' ) ;
76
85
commander . outputHelp ( ) ;
77
86
process . exit ( 1 ) ;
78
87
}
79
88
_createBucketWithNFSEnabled ( host , port , bucket , accessKey , secretKey ,
80
- verbose , ssl ) ;
89
+ verbose , ssl , locationConstraint ) ;
81
90
}
82
91
83
92
module . exports = {
0 commit comments