爱简单吧

分享简单,爱生活,爱简单

七牛网盘推荐

现在网盘很多,抢用户的方式也各式各样,看了七牛的API,使用还挺方便,注册后可获得永久10G空间和每月10G流量,挺吸引人。





测试了一下,七牛网盘文件上传示例:

七牛网盘上传文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import qiniu.conf
import qiniu.rs
import qiniu.io

qiniu.conf.ACCESS_KEY = "xxxxxxxxxxxxxxxx"
qiniu.conf.SECRET_KEY = "xxxxxxxxxxxxxxxx"
bucket_name = "your_bucket_name"

policy = qiniu.rs.PutPolicy(bucket_name)
uptoken = policy.token()

key = "test.txt"
ret, err = qiniu.io.put(uptoken, key, file_data="test string data")
if err is not None:
    print err
file_url = "http://%s.qiniudn.com/%s" % (bucket_name, key)
print file_url

七牛删除文件示例

七牛删除文件
1
2
3
4
5
6
7
8
9
10
11
import qiniu.conf
import qiniu.rs

qiniu.conf.ACCESS_KEY = "xxxxxxxxxxxxxxxx"
qiniu.conf.SECRET_KEY = "xxxxxxxxxxxxxxxx"
bucket_name = "your_bucket_name"

key = "test.txt"
ret, err = qiniu.rs.Client().delete(bucket_name, key)
if err is not None:
    return err

下面一张图片来自七牛网盘:

图片:qiniu.gif

qiniu.gif

注册可获10G空间及每月10G流量,有空可试试,推荐注册链接

 

Share

 

Comments