Setting Access-Control-Allow-Origin (CORS) in the Rackspace Cloud Files Python API

旧时模样 提交于 2019-12-08 13:14:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!