Skip to content

Commit 84a44d3

Browse files
authored
Merge pull request #2 from qiniu/master
merge from master
2 parents 3b3babf + d5fa041 commit 84a44d3

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

examples/timestamp_url.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@
2525
timestamp_url = create_timestamp_anti_leech_url(host, file_name, query_string, encrypt_key, deadline)
2626

2727
print(timestamp_url)
28-
29-
30-

examples/upload_with_zone.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
from qiniu import Auth, put_file, etag, urlsafe_base64_encode
5+
import qiniu.config
6+
from qiniu import Zone, set_default
7+
8+
# 需要填写你的 Access Key 和 Secret Key
9+
access_key = '...'
10+
secret_key = '...'
11+
12+
# 构建鉴权对象
13+
q = Auth(access_key, secret_key)
14+
15+
# 要上传的空间
16+
bucket_name = 'Bucket_Name'
17+
18+
# 上传到七牛后保存的文件名
19+
key = 'my-python-logo.png';
20+
21+
# 生成上传 Token,可以指定过期时间等
22+
token = q.upload_token(bucket_name, key, 3600)
23+
24+
# 要上传文件的本地路径
25+
localfile = 'stat.py'
26+
27+
# 指定固定的zone
28+
zone = Zone(up_host='uptest.qiniu.com', up_host_backup='uptest.qiniu.com', io_host='iovip.qbox.me', scheme='http')
29+
set_default(default_zone=zone)
30+
31+
ret, info = put_file(token, key, localfile)
32+
print(info)
33+
assert ret['key'] == key
34+
assert ret['hash'] == etag(localfile)

qiniu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# flake8: noqa
1111

12-
__version__ = '7.1.4'
12+
__version__ = '7.1.5'
1313

1414
from .auth import Auth, QiniuMacAuth
1515

qiniu/auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'persistentPipeline', # 持久化处理独享队列
3737
'deleteAfterDays', # 文件多少天后自动删除
3838
'fileType', # 文件的存储类型,0为普通存储,1为低频存储
39+
'isPrefixalScope' # 指定上传文件必须使用的前缀
3940
])
4041

4142

qiniu/zone.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ def get_bucket_hosts(self, ak, bucket):
8080
hosts[self.scheme].update({'up': []})
8181
hosts[self.scheme].update({'io': []})
8282

83-
if self.up_host != None:
83+
if self.up_host is not None:
8484
hosts[self.scheme]['up'].append(self.scheme + "://" + self.up_host)
8585

86-
if self.up_host_backup != None:
86+
if self.up_host_backup is not None:
8787
hosts[self.scheme]['up'].append(self.scheme + "://" + self.up_host_backup)
8888

89-
if self.io_host != None:
89+
if self.io_host is not None:
9090
hosts[self.scheme]['io'].append(self.scheme + "://" + self.io_host)
9191

92-
if len(hosts[self.scheme]) == 0 or self.io_host == None:
92+
if len(hosts[self.scheme]) == 0 or self.io_host is None:
9393
# print(hosts)
9494
hosts = compat.json.loads(self.bucket_hosts(ak, bucket))
9595
else:

0 commit comments

Comments
 (0)