hexo/node_modules/ali-oss/lib/common/bucket/getBucketPolicy.js

29 lines
677 B
JavaScript
Raw Normal View History

2023-09-25 15:58:56 +08:00
const { checkBucketName: _checkBucketName } = require('../utils/checkBucketName');
const proto = exports;
/**
* getBucketPolicy
* @param {String} bucketName - bucket name
* @param {Object} options
*/
proto.getBucketPolicy = async function getBucketPolicy(bucketName, options = {}) {
_checkBucketName(bucketName);
const params = this._bucketRequestParams('GET', bucketName, 'policy', options);
const result = await this.request(params);
params.successStatuses = [200];
let policy = null;
if (result.res.status === 200) {
policy = JSON.parse(result.res.data.toString());
}
return {
policy,
status: result.status,
res: result.res
};
};