本地文件上传到七牛云服务器示例(七牛云存储)
程序员文章站
2024-01-28 22:22:04
复制代码 代码如下:# _*_ coding: utf-8 _*_#---------------------------------------# ...
复制代码 代码如下:
# _*_ coding: utf-8 _*_
#---------------------------------------
# 程序:把本地文件上传到七牛云服务器
# 版本:0.1
# 作者:liu jia
# 日期:2014-01-07
# 语言:python 2.7
#---------------------------------------
import qiniu.conf
import sys
import os
#登录后从#https://portal.qiniu.com/setting/key获取
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()
上一篇: 小如蜜蜂的无人机Robobee