diff --git a/lib/bucket.js b/lib/bucket.js index 1df360262..265a474c9 100644 --- a/lib/bucket.js +++ b/lib/bucket.js @@ -202,9 +202,19 @@ proto.deleteBucketLogging = async function deleteBucketLogging(name, options) { }; }; -proto.putBucketCORS = async function putBucketCORS(name, rules, options) { +proto.putBucketCORS = async function putBucketCORS(name, rulesOrConfiguration, options) { _checkBucketName(name); - rules = rules || []; + + let rules = []; + let responseVary; + + if (isArray(rulesOrConfiguration)) { + rules = rulesOrConfiguration || []; + } else { + rules = rulesOrConfiguration.rules || []; + responseVary = rulesOrConfiguration.responseVary; + } + assert(rules.length, 'rules is required'); rules.forEach((rule) => { assert(rule.allowedOrigin, 'allowedOrigin is required'); @@ -238,6 +248,11 @@ proto.putBucketCORS = async function putBucketCORS(name, rules, options) { } xml += ''; } + + if (typeof responseVary === 'boolean') { + xml += `${responseVary.toString()}`; + } + xml += ''; params.content = xml; params.mime = 'xml';