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.
37 lines
1.1 KiB
37 lines
1.1 KiB
1 month ago
|
const proto = exports;
|
||
|
// const jstoxml = require('jstoxml');
|
||
|
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName');
|
||
|
const { obj2xml } = require('../utils/obj2xml');
|
||
|
/**
|
||
|
* putBucketEncryption
|
||
|
* @param {String} bucketName - bucket name
|
||
|
* @param {Object} options
|
||
|
*/
|
||
|
|
||
|
proto.putBucketEncryption = async function putBucketEncryption(bucketName, options) {
|
||
|
options = options || {};
|
||
|
_checkBucketName(bucketName);
|
||
|
const params = this._bucketRequestParams('PUT', bucketName, 'encryption', options);
|
||
|
params.successStatuses = [200];
|
||
|
const paramXMLObj = {
|
||
|
ServerSideEncryptionRule: {
|
||
|
ApplyServerSideEncryptionByDefault: {
|
||
|
SSEAlgorithm: options.SSEAlgorithm
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
if (options.KMSMasterKeyID !== undefined) {
|
||
|
paramXMLObj.ServerSideEncryptionRule.ApplyServerSideEncryptionByDefault.KMSMasterKeyID = options.KMSMasterKeyID;
|
||
|
}
|
||
|
const paramXML = obj2xml(paramXMLObj, {
|
||
|
headers: true
|
||
|
});
|
||
|
params.mime = 'xml';
|
||
|
params.content = paramXML;
|
||
|
const result = await this.request(params);
|
||
|
return {
|
||
|
status: result.status,
|
||
|
res: result.res
|
||
|
};
|
||
|
};
|