Created
August 8, 2012 16:03
-
-
Save ipconfiger/3296216 to your computer and use it in GitHub Desktop.
BAE中使用云存储的简单wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf8 | |
import pybcs | |
import logging | |
pybcs.init_logging(logging.INFO) | |
AK = '' #请改为你的AK | |
SK = '' #请改为你的SK | |
BUCKET='myimage1' | |
bcs = pybcs.BCS('http://bcs.duapp.com/', AK, SK) | |
def dump_file(filename,file_obj): | |
b = bcs.bucket(BUCKET) | |
o = b.object('/%s'%filename) | |
o.put(file_obj) | |
def read_file(filename): | |
b = bcs.bucket(BUCKET) | |
o = b.object('/%s'%filename) | |
return o.get() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment