Skip to content

Instantly share code, notes, and snippets.

@ma6174
Last active December 27, 2015 17:59
Show Gist options
  • Save ma6174/7366814 to your computer and use it in GitHub Desktop.
Save ma6174/7366814 to your computer and use it in GitHub Desktop.
七牛文件上传脚本
#!/usr/bin/env python
# coding=utf-8
import sys
import qiniu.conf
import qiniu.rs
import qiniu.io
qiniu.conf.ACCESS_KEY = '*****************'
qiniu.conf.SECRET_KEY = '*****************'
bucket = '***************'
policy = qiniu.rs.PutPolicy(bucket)
uptoken = policy.token()
if len(sys.argv) < 2:
print "usage: %s file1 file2 file3 ..." % sys.argv[0]
exit()
for i in sys.argv[1:]:
ret, err = qiniu.io.put_file(uptoken, i, i)
if err:
print i, err
url = "http://%s.u.qiniudn.com/%s" % (bucket, i)
print url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment