Copy codeThe Code is as follows:
# _ * _ Coding: UTF-8 _*_
#---------------------------------------
# Program: upload local files to qiniu ECs
# Version 0.1
# Author: liu jia
# Date:
# Programming language: Python 2.7
#---------------------------------------
Import qiniu. conf
Import sys
Import OS
# After logging on to the console, you can obtain it from # https://portal.qiniu.com/setting/key
Qiniu. conf. ACCESS_KEY = "xxxxxxxxxxxxxxxxx"
Qiniu. conf. SECRET_KEY = "xxxxxxxxxxxxxxxxx"
Import qiniu. io
Import qiniu. rs
Policy = qiniu. rs. PutPolicy ('xxxxx') # The space name is 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 'doubanque ')
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 ()