def set_cors_xml(self, cors_xml, headers=None):
"""
Set the CORS (Cross-Origin Resource Sharing) for a bucket.
:type cors_xml: str
:param cors_xml: The XML document describing your desired
CORS configuration. See the S3 documentation for details
of the exact syntax required.
"""
fp = StringIO(cors_xml)
md5 = boto.utils.compute_md5(fp)
if headers is None:
headers = {}
headers['Content-MD5'] = md5[1]
headers['Content-Type'] = 'text/xml'
response = self.connection.make_request('PUT', self.name,
data=fp.getvalue(),
query_args='cors',
headers=headers)
body = response.read()
if response.status == 200:
return True
else:
raise self.connection.provider.storage_response_error(
response.status, response.reason, body)
评论列表
文章目录