Created
August 8, 2012 16:58
-
-
Save idning/3296652 to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
import logging | |
import pybcs | |
#设置日志级别 | |
pybcs.init_logging(logging.INFO) | |
AK = os.environ['AK'] #请改为你的AK | |
SK = os.environ['SK'] #请改为你的SK | |
BUCKET='bcs-test' | |
bcs = pybcs.BCS('http://bcs.duapp.com/', AK, SK, pybcs.HttplibHTTPC) | |
lst = bcs.list_buckets() | |
print '---------------- list of bucket : ' | |
for b in lst: | |
print b | |
print '---------------- list end' | |
#声明一个bucket | |
b = bcs.bucket(BUCKET) | |
#创建bucket (创建后需要在yun.baidu.com 手动调整quota, 否则无法上传下载) | |
#b.create() | |
#获取bucket acl, 内容是json | |
print b.get_acl()['body'] | |
#将bucket 设置为公有可读写 | |
#b.make_public() | |
#声明一个object | |
o = b.object('/object_name_should_start_with_slash') | |
o.put(file('ttt').read()) | |
o.put_file(file('ttt').read()) #这样就出错!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
#将本地的README 文件上传到 | |
o.put_file('README.md') | |
#下载文件到 README.download | |
o.get_to_file('test/data/README.download.data') | |
o.delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment