Skip to content

Release v6.1.3 #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

### v6.1.3

2013-08-26 issue []
2013-10-24 issue [#77](https://github.com/qiniu/python-sdk/pull/77)

- bug fix, httplib_thunk.py 中的无效符号引用
- PutPolicy:增加 saveKey、persistentOps/persistentNotifyUrl、fsizeLimit(文件大小限制)等支持
- 断点续传:使用新的 mkfile 协议


### v6.1.2

Expand All @@ -14,12 +17,14 @@
- 修复在Windows环境下创建临时文件的权限问题
- 修复在Windows环境下对二进制文件计算crc32的bug


### v6.1.1

2013-07-05 issue [#60](https://github.com/qiniu/python-sdk/pull/60)

- 整理文档


### v6.1.0

2013-07-03 issue [#58](https://github.com/qiniu/python-sdk/pull/58)
Expand Down
16 changes: 7 additions & 9 deletions qiniu/resumable_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def gen_crc32(data):
return binascii.crc32(data) & 0xffffffff

class PutExtra(object):
callback_params = None # 当 uptoken 指定了 CallbackUrl,则 CallbackParams 必须非空
bucket = None # 当前是必选项,但未来会去掉
custom_meta = None # 可选。用户自定义 Meta,不能超过 256 字节
params = None # 自定义用户变量, key需要x: 开头
mimetype = None # 可选。在 uptoken 没有指定 DetectMime 时,用户客户端可自己指定 MimeType
chunk_size = None # 可选。每次上传的Chunk大小
try_times = None # 可选。尝试次数
Expand Down Expand Up @@ -153,17 +151,17 @@ def putblock(client, block_ret, chunk):
return client.call_with(url, chunk, content_type, len(chunk))

def mkfile(client, key, fsize, extra):
encoded_entry = urlsafe_b64encode("%s:%s" % (extra.bucket, key))
url = ["http://%s/rs-mkfile/%s/fsize/%s" % (conf.UP_HOST, encoded_entry, fsize)]
url = ["http://%s/mkfile/%s" % (conf.UP_HOST, fsize)]

if extra.mimetype:
url.append("mimeType/%s" % urlsafe_b64encode(extra.mimetype))

if extra.custom_meta:
url.append("meta/%s" % urlsafe_b64encode(extra.custom_meta))
if key is not None:
url.append("key/%s" % urlsafe_b64encode(key))

if extra.callback_params:
url.append("params/%s" % urlsafe_b64encode(extra.callback_params))
if extra.params:
for k, v in extra.params.iteritems():
url.append("%s/%s" % (k, urlsafe_b64encode(v)))

url = "/".join(url)
body = ",".join([i["ctx"] for i in extra.progresses])
Expand Down
29 changes: 27 additions & 2 deletions qiniu/rs/rs_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ class PutPolicy(object):
endUser = None
asyncOps = None

saveKey = None
insertOnly = None
detectMime = None
fsizeLimit = None
persistentNotifyUrl = None
persistentOps = None

def __init__(self, scope):
self.scope = scope
# @endgist
Expand Down Expand Up @@ -46,15 +53,33 @@ def token(self, mac=None):

if self.asyncOps is not None:
token["asyncOps"] = self.asyncOps


if self.saveKey is not None:
token["saveKey"] = self.saveKey

if self.insertOnly is not None:
token["exclusive"] = self.insertOnly

if self.detectMime is not None:
token["detectMime"] = self.detectMime

if self.fsizeLimit is not None:
token["fsizeLimit"] = self.fsizeLimit

if self.persistentOps is not None:
token["persistentOps"] = self.persistentOps

if self.persistentNotifyUrl is not None:
token["persistentNotifyUrl"] = self.persistentNotifyUrl

b = json.dumps(token, separators=(',',':'))
return mac.sign_with_data(b)

class GetPolicy(object):
expires = 3600
def __init__(self):
pass

def make_request(self, base_url, mac=None):
'''
* return private_url
Expand Down
2 changes: 2 additions & 0 deletions qiniu/test/resumable_io_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ def test_put(self):
policy = rs.PutPolicy(bucket)
extra = resumable_io.PutExtra(bucket)
extra.bucket = bucket
extra.params = {"x:foo": "test"}
key = "sdk_py_resumable_block_5_%s" % r(9)
localfile = dst.name
ret, err = resumable_io.put_file(policy.token(), key, localfile, extra)
assert ret.get("x:foo") == "test", "return data not contains 'x:foo'"
dst.close()
os.remove(tmpf)

Expand Down