Skip to content

Commit

Permalink
增加 deleteBucketPolicy 接口
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Sep 28, 2018
1 parent 7665f7f commit fa00a7f
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 4 deletions.
10 changes: 10 additions & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ function getBucketPolicy() {
});
}

function deleteBucketPolicy() {
cos.deleteBucketPolicy({
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region
}, function (err, data) {
logger.log(err || data);
});
}

function getBucketLocation() {
cos.getBucketLocation({
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Expand Down Expand Up @@ -775,6 +784,7 @@ function sliceCopyFile() {
'deleteBucketTagging',
'putBucketPolicy',
'getBucketPolicy',
'deleteBucketPolicy',
'getBucketLocation',
'getBucketLifecycle',
'putBucketLifecycle',
Expand Down
33 changes: 32 additions & 1 deletion dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.16';
COS.version = '0.4.17';

module.exports = COS;

Expand Down Expand Up @@ -4216,6 +4216,36 @@ function putBucketPolicy(params, callback) {
});
}

/**
* 删除 Bucket 的 跨域设置
* @param {Object} params 参数对象,必须
* @param {String} params.Bucket Bucket名称,必须
* @param {String} params.Region 地域名称,必须
* @param {Function} callback 回调函数,必须
* @return {Object} err 请求失败的错误,如果请求成功,则为空。https://cloud.tencent.com/document/product/436/7730
* @return {Object} data 返回的数据
*/
function deleteBucketPolicy(params, callback) {
submitRequest.call(this, {
method: 'DELETE',
Bucket: params.Bucket,
Region: params.Region,
headers: params.Headers,
action: 'policy'
}, function (err, data) {
debugger;
if (err && err.statusCode === 204) {
return callback(null, { statusCode: err.statusCode });
} else if (err) {
return callback(err);
}
callback(null, {
statusCode: data.statusCode || err.statusCode,
headers: data.headers
});
});
}

/**
* 获取 Bucket 的 地域信息
* @param {Object} params 参数对象,必须
Expand Down Expand Up @@ -5897,6 +5927,7 @@ var API_MAP = {
deleteBucketTagging: deleteBucketTagging,
getBucketPolicy: getBucketPolicy,
putBucketPolicy: putBucketPolicy,
deleteBucketPolicy: deleteBucketPolicy,
getBucketLifecycle: getBucketLifecycle,
putBucketLifecycle: putBucketLifecycle,
deleteBucketLifecycle: deleteBucketLifecycle,
Expand Down
2 changes: 1 addition & 1 deletion dist/cos-js-sdk-v5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cos-js-sdk-v5",
"version": "0.4.16",
"version": "0.4.17",
"description": "cos js sdk v5",
"main": "index.js",
"scripts": {
Expand Down
31 changes: 31 additions & 0 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,36 @@ function putBucketPolicy(params, callback) {
});
}

/**
* 删除 Bucket 的 跨域设置
* @param {Object} params 参数对象,必须
* @param {String} params.Bucket Bucket名称,必须
* @param {String} params.Region 地域名称,必须
* @param {Function} callback 回调函数,必须
* @return {Object} err 请求失败的错误,如果请求成功,则为空。https://cloud.tencent.com/document/product/436/7730
* @return {Object} data 返回的数据
*/
function deleteBucketPolicy(params, callback) {
submitRequest.call(this, {
method: 'DELETE',
Bucket: params.Bucket,
Region: params.Region,
headers: params.Headers,
action: 'policy',
}, function (err, data) {
debugger;
if (err && err.statusCode === 204) {
return callback(null, {statusCode: err.statusCode});
} else if (err) {
return callback(err);
}
callback(null, {
statusCode: data.statusCode || err.statusCode,
headers: data.headers,
});
});
}

/**
* 获取 Bucket 的 地域信息
* @param {Object} params 参数对象,必须
Expand Down Expand Up @@ -2075,6 +2105,7 @@ var API_MAP = {
deleteBucketTagging: deleteBucketTagging,
getBucketPolicy: getBucketPolicy,
putBucketPolicy: putBucketPolicy,
deleteBucketPolicy: deleteBucketPolicy,
getBucketLifecycle: getBucketLifecycle,
putBucketLifecycle: putBucketLifecycle,
deleteBucketLifecycle: deleteBucketLifecycle,
Expand Down
2 changes: 1 addition & 1 deletion src/cos.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ util.extend(COS.prototype, base);
util.extend(COS.prototype, advance);

COS.getAuthorization = util.getAuth;
COS.version = '0.4.16';
COS.version = '0.4.17';

module.exports = COS;

0 comments on commit fa00a7f

Please sign in to comment.