问题
I'm trying to enable CORS on my Rackspace Cloud Files. According to the docs, I can add the Access-Control-Allow-Origin
header, but I don't see how to do that with the Python python-cloudfiles module API:
conn = cloudfiles.get_connection('apaidnerd', 's3cr3t')
container = conn.get_container('warez')
obj = container.create_object('foo.png')
obj.load_from_filename('/path/to/foo.png')
# ...what's next?
Help?
回答1:
Use the undocumented headers
property of Object
:
obj.headers['Access-Control-Allow-Origin'] = '*'
obj.sync_metadata()
来源:https://stackoverflow.com/questions/10424443/setting-access-control-allow-origin-cors-in-the-rackspace-cloud-files-python-a