-
Notifications
You must be signed in to change notification settings - Fork 576
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
6 changed files
with
181 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const proto = exports; | ||
/** | ||
* deleteBucketPolicy | ||
* @param {String} bucketName - bucket name | ||
* @param {Object} options | ||
*/ | ||
|
||
proto.deleteBucketPolicy = async function deleteBucketPolicy(bucketName, options = {}) { | ||
this._checkBucketName(bucketName); | ||
|
||
const params = this._bucketRequestParams('DELETE', bucketName, 'policy', options); | ||
|
||
const result = await this.request(params); | ||
|
||
return { | ||
status: result.status, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const proto = exports; | ||
/** | ||
* getBucketPolicy | ||
* @param {String} bucketName - bucket name | ||
* @param {Object} options | ||
*/ | ||
|
||
proto.getBucketPolicy = async function getBucketPolicy(bucketName, options = {}) { | ||
this._checkBucketName(bucketName); | ||
|
||
const params = this._bucketRequestParams('GET', bucketName, 'policy', options); | ||
|
||
const result = await this.request(params); | ||
|
||
let policy = null; | ||
|
||
if (result.res.status === 200) { | ||
policy = JSON.parse(result.res.data.toString()); | ||
} | ||
|
||
return { | ||
policy, | ||
status: result.status, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
const policy2Str = require('../utils/policy2Str'); | ||
const isObject = require('../utils/isObject'); | ||
|
||
const proto = exports; | ||
/** | ||
* putBucketPolicy | ||
* @param {String} bucketName - bucket name | ||
* @param {Object} policy - bucket policy | ||
* @param {Object} options | ||
*/ | ||
|
||
proto.putBucketPolicy = async function putBucketPolicy(bucketName, policy, options = {}) { | ||
this._checkBucketName(bucketName); | ||
|
||
if (!isObject(policy)) { | ||
throw new Error('policy is not Object'); | ||
} | ||
const params = this._bucketRequestParams('PUT', bucketName, 'policy', options); | ||
params.content = policy2Str(policy); | ||
|
||
const result = await this.request(params); | ||
return { | ||
status: result.status, | ||
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