复制代码 代码如下:
import qiniu.conf
import sys
import os
qiniu.conf.ACCESS_KEY = "xxxxxxxxxxxxxxxxxxx"
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()
print path
picture_path = os.path.join(path, u'豆瓣妹子')
for item in os.listdir(picture_path):
item = picture_path+'\\'+item
ret, err = qiniu.io.put_file(uptoken, None, item, extra)
print item+'---------uploaded'
if err is not None:
sys.stderr.write('error: %s ' % err)
exit()
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8