import qiniu.conf
import sys
import os
#ログイン後に #https://portal.qiniu.com/setting/key から取得します
qiniu.conf.ACCESS_KEY = "xxxxxxxxxxxxxxxxxxxxx "
qiniu.conf.SECRET_KEY = "xxxxxxxxxxxxxxxxxxx"
import qiniu.io
import qiniu.rs
policy = qiniu.rs.PutPolicy('xxxxx')# スペース名はbucket_name
uptoken =policy.token()
extra = qiniu.io.PutExtra()
extra.mime_type = "image/jpeg"
path = os.getcwd()
印刷パス
picture_path = os.path.join(path, u'Doubanmeizi')
os.listdir(picture_path) の項目:
item = picture_path+'\'+item
ret, err = qiniu.io.put_file(uptoken, None, item, extra)
print item+'--------uploaded'
if err None ではありません:
sys.stderr.write('error: %s ' % err)
exit()