Example of uploading local files to qiniu ECS (qiniu cloud storage)

Source: Internet
Author: User

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 ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.