-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
39 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const checkBucketName = require('../utils/checkBucketName'); | ||
|
||
const proto = exports; | ||
|
||
proto._checkBucketName = function (name, createBucket) { | ||
if (!checkBucketName(name, createBucket)) { | ||
throw new Error('The bucket must be conform to the specifications'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const proto = exports; | ||
const obj2xml = require('../utils/obj2xml'); | ||
|
||
proto.putBucket = async function putBucket(name, options) { | ||
this._checkBucketName(name, true); | ||
options = options || {}; | ||
const params = this._bucketRequestParams('PUT', name, '', options); | ||
|
||
const CreateBucketConfiguration = {}; | ||
const paramlXMLObJ = { | ||
CreateBucketConfiguration | ||
}; | ||
|
||
if (options.StorageClass) { | ||
CreateBucketConfiguration.StorageClass = options.StorageClass; | ||
params.mime = 'xml'; | ||
params.content = obj2xml(paramlXMLObJ, { headers: true }); | ||
} | ||
|
||
params.successStatuses = [200]; | ||
const result = await this.request(params); | ||
return { | ||
bucket: (result.headers.location && result.headers.location.substring(1)) || null, | ||
res: result.res | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters