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.
parttimejob/node_modules/ali-oss/lib/common/bucket/putBucketVersioning.js

36 lines
884 B

1 month ago
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName');
const { obj2xml } = require('../utils/obj2xml');
const proto = exports;
/**
* putBucketVersioning
* @param {String} name - bucket name
* @param {String} status
* @param {Object} options
*/
proto.putBucketVersioning = async function putBucketVersioning(name, status, options = {}) {
_checkBucketName(name);
if (!['Enabled', 'Suspended'].includes(status)) {
throw new Error('status must be Enabled or Suspended');
}
const params = this._bucketRequestParams('PUT', name, 'versioning', options);
const paramXMLObj = {
VersioningConfiguration: {
Status: status
}
};
params.mime = 'xml';
params.content = obj2xml(paramXMLObj, {
headers: true
});
const result = await this.request(params);
return {
res: result.res,
status: result.status
};
};