Skip to content

Commit b4be3cb

Browse files
authored
Merge branch 'master' into features/add-decode-except
2 parents 3de48b3 + c160e08 commit b4be3cb

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 7.5.0 (2021-09-23)
4+
* 上传策略新增对部分字段支持
5+
6+
## 7.4.1 (2021-05-25)
7+
* 分片上传 v2 方法不再强制要求 bucket_name 参数
8+
39
## 7.4.0 (2021-05-21)
410
* 支持分片上传 v2
511

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
5-
[![Build Status](https://travis-ci.org/qiniu/python-sdk.svg)](https://travis-ci.org/qiniu/python-sdk)
5+
[![Build Status](https://github.com/qiniu/python-sdk/actions/workflows/ci-test.yml/badge.svg)](https://travis-ci.org/qiniu/python-sdk)
66
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/python-sdk.svg?label=release)](https://github.com/qiniu/python-sdk/releases)
77
[![Latest Stable Version](https://img.shields.io/pypi/v/qiniu.svg)](https://pypi.python.org/pypi/qiniu)
88
[![Download Times](https://img.shields.io/pypi/dm/qiniu.svg)](https://pypi.python.org/pypi/qiniu)
@@ -19,10 +19,10 @@ $ pip install qiniu
1919

2020
## 运行环境
2121

22-
| Qiniu SDK版本 | Python 版本 |
23-
|:--------------------:|:---------------------------:|
24-
| 7.x | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9|
25-
| 6.x | 2.7 |
22+
| Qiniu SDK版本 | Python 版本 |
23+
| :-----------: | :------------------------------------: |
24+
| 7.x | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9 |
25+
| 6.x | 2.7 |
2626

2727
## 使用方法
2828

@@ -44,11 +44,6 @@ import qiniu
4444

4545
```
4646
更多参见SDK使用指南: http://developer.qiniu.com/code/v7/sdk/python.html
47-
48-
### 命令行工具
49-
安装完后附带有命令行工具,可以计算etag
50-
```bash
51-
$ qiniupy etag yourfile
5247
```
5348
5449
## 测试

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.4.0'
12+
__version__ = '7.5.0'
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
@@ -28,6 +28,7 @@
2828
'mimeLimit', # MimeType限制
2929
'fsizeLimit', # 上传文件大小限制
3030
'fsizeMin', # 上传文件最少字节数
31+
'keylimit', # 设置允许上传的key列表,字符串数组类型,数组长度不可超过20个,如果设置了这个字段,上传时必须提供key
3132

3233
'persistentOps', # 持久化处理操作
3334
'persistentNotifyUrl', # 持久化处理结果通知URL

test_qiniu.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,23 @@ def test_retry(self):
481481
assert ret['key'] == key
482482
assert ret['hash'] == etag(localfile)
483483

484+
def test_put_stream_with_key_limits(self):
485+
localfile = __file__
486+
key = 'test_file_r'
487+
size = os.stat(localfile).st_size
488+
set_default(default_zone=Zone('http://upload.qiniup.com'))
489+
with open(localfile, 'rb') as input_stream:
490+
token = self.q.upload_token(bucket_name, key, policy={'keylimit': ['test_file_d']})
491+
ret, info = put_stream(token, key, input_stream, os.path.basename(__file__), size, hostscache_dir,
492+
self.params,
493+
self.mime_type)
494+
assert info.status_code == 403
495+
token = self.q.upload_token(bucket_name, key, policy={'keylimit': ['test_file_d', 'test_file_r']})
496+
ret, info = put_stream(token, key, input_stream, os.path.basename(__file__), size, hostscache_dir,
497+
self.params,
498+
self.mime_type)
499+
assert info.status_code == 200
500+
484501

485502
class DownloadTestCase(unittest.TestCase):
486503
q = Auth(access_key, secret_key)

0 commit comments

Comments
 (0)