You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
820 B
28 lines
820 B
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName');
|
|
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 = {}) {
|
|
_checkBucketName(bucketName);
|
|
|
|
if (!isObject(policy)) {
|
|
throw new Error('policy is not Object');
|
|
}
|
|
const params = this._bucketRequestParams('PUT', bucketName, 'policy', options);
|
|
params.content = policy2Str(policy);
|
|
params.successStatuses = [200];
|
|
const result = await this.request(params);
|
|
return {
|
|
status: result.status,
|
|
res: result.res
|
|
};
|
|
};
|