a paid nerd
a paid nerd

Reputation: 31522

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

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?

Upvotes: 0

Views: 1557

Answers (1)

a paid nerd
a paid nerd

Reputation: 31522

Use the undocumented headers property of Object:

obj.headers['Access-Control-Allow-Origin'] = '*'                                               
obj.sync_metadata()                  

Upvotes: 2

Related Questions