在Rackspace云文件Python API中设置访问控制允许原因(CORS) [英] Setting Access-Control-Allow-Origin (CORS) in the Rackspace Cloud Files Python API

查看:172
本文介绍了在Rackspace云文件Python API中设置访问控制允许原因(CORS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Rackspace云端档案中启用CORS 。根据文档,我可以添加 Access-Control-Allow-Origin 标头,但我不知道如何使用 Python python-cloudfiles 模块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?

帮助?

推荐答案

使用对象的未记录的属性:

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

这篇关于在Rackspace云文件Python API中设置访问控制允许原因(CORS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆