我想操作存储在Google App Engine沙盒中的S3中的pickled python对象。我用博托的建议documentation:
from boto.s3.connection import S3Connection
from boto.s3.key import Key
conn = S3Connection(config.key, config.secret_key)
bucket = conn.get_bucket('bucketname')
key = bucket.get_key("picture.jpg")
fp = open ("picture.jpg", "w")
key.get_file (fp)
但这需要我写一个文件,这显然是不洁的GAE沙箱。
我怎么能避开这个? 非常感谢你的帮助
你根本不需要写文件或字符串。您可以调用
key.get_contents_as_string()
将键的内容作为字符串返回。key的文档是here。可以写入blob并使用StringIO检索数据
相关问题 更多 >
编程相关推荐