Skip to content
Browse files

Merge pull request #77 from qiniu/develop

Release v6.1.3
  • Loading branch information...
2 parents 64aa811 + e2aebfe commit 7a5a963d3463b9c98e569efcb904533d3e6aa9ae @xushiwei xushiwei committed
Showing with 42 additions and 12 deletions.
  1. +6 −1 CHANGELOG.md
  2. +7 −9 qiniu/resumable_io.py
  3. +27 −2 qiniu/rs/rs_token.py
  4. +2 −0 qiniu/test/resumable_io_test.py
View
7 CHANGELOG.md
@@ -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
@@ -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)
View
16 qiniu/resumable_io.py
@@ -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 # 可选。尝试次数
@@ -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])
View
29 qiniu/rs/rs_token.py
@@ -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
@@ -46,7 +53,25 @@ 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)
@@ -54,7 +79,7 @@ class GetPolicy(object):
expires = 3600
def __init__(self):
pass
-
+
def make_request(self, base_url, mac=None):
'''
* return private_url
View
2 qiniu/test/resumable_io_test.py
@@ -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)

0 comments on commit 7a5a963

Please sign in to comment.
Something went wrong with that request. Please try again.