Skip to content

Commit 7e452d7

Browse files
committed
fix
1 parent e01dc3b commit 7e452d7

File tree

5 files changed

+20
-33
lines changed

5 files changed

+20
-33
lines changed

docs/README.gist.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ Python-SDK 被设计为同时适合服务器端和客户端使用。服务端是
8282
#或
8383
easy_install qiniu
8484

85-
Tornado is listed in PyPI and can be installed with pip or easy_install. Note that the source distribution includes demo applications that are not present when Tornado is installed in this way, so you may wish to download a copy of the source tarball as well.
8685
Python-SDK可以使用`pip``easy_install`从PyPI服务器上安装,但不包括文档和样例。如果需要,请下载源码并安装。
8786

8887
源码安装:
@@ -155,7 +154,7 @@ Python-SDK可以使用`pip`或`easy_install`从PyPI服务器上安装,但不
155154

156155
##### 上传策略
157156

158-
[uptoken](http://docs.qiniu.com/api/put.html#uploadToken) 实际上是用 AccessKey/SecretKey 进行数字签名的上传策略(`qiniu/rs/PutPolicy`),它控制则整个上传流程的行为。让我们快速过一遍你都能够决策啥:
157+
[uptoken](http://docs.qiniu.com/api/put.html#uploadToken) 实际上是用 AccessKey/SecretKey 进行数字签名的上传策略(`qiniu.rs.PutPolicy`),它控制则整个上传流程的行为。让我们快速过一遍你都能够决策啥:
159158

160159
```{python}
161160
@gist(../qiniu/rs/rs_token.py#PutPolicy)
@@ -197,7 +196,10 @@ PutExtra是上传时的可选信息,默认为None
197196
* `params` 是一个字典。[自定义变量](http://docs.qiniu.com/api/put.html#xVariables),key必须以 x: 开头命名,不限个数。可以在 uploadToken 的 callbackBody 选项中求值。
198197
* `mime_type` 表示数据的MimeType。
199198
* `crc32` 待检查的crc32值
200-
* `check_crc` 可选值为0, 1, 2。 `check_crc=0`: 表示不进行 crc32 校验。`check_crc=1`: 对于 put 等同于 `check_crc=2`;对于 put_file 会自动计算 crc32 值。`check_crc == 2`: 表示进行 crc32 校验,且 crc32 值就是上面的 crc32 变量
199+
* `check_crc` 可选值为0, 1, 2。
200+
`check_crc == 0`: 表示不进行 crc32 校验。
201+
`check_crc == 1`: 上传二进制数据时等同于 `check_crc=2`;上传本地文件时会自动计算 crc32 值。
202+
`check_crc == 2`: 表示进行 crc32 校验,且 crc32 值就是上面的 `crc32` 变量
201203

202204
<a name="upload-do"></a>
203205

@@ -292,7 +294,7 @@ ret是一个字典,含有`hash`,`key`等信息。
292294

293295
#### 断点续下载
294296

295-
无论是公有资源还是私有资源,获得的下载 url 支持标准的 HTTP 断点续传协议。考虑到多数语言都有相应的断点续下载支持的成熟方法,七牛 C-SDK 并不提供断点续下载相关代码。
297+
无论是公有资源还是私有资源,获得的下载 url 支持标准的 HTTP 断点续传协议。考虑到多数语言都有相应的断点续下载支持的成熟方法,七牛 Python-SDK 并不提供断点续下载相关代码。
296298

297299
<a name="rs"></a>
298300

docs/README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ Python-SDK 被设计为同时适合服务器端和客户端使用。服务端是
8282
#或
8383
easy_install qiniu
8484

85-
Tornado is listed in PyPI and can be installed with pip or easy_install. Note that the source distribution includes demo applications that are not present when Tornado is installed in this way, so you may wish to download a copy of the source tarball as well.
8685
Python-SDK可以使用`pip``easy_install`从PyPI服务器上安装,但不包括文档和样例。如果需要,请下载源码并安装。
8786

8887
源码安装:
@@ -158,7 +157,7 @@ qiniu.conf.SECRET_KEY = "<YOUR_APP_SECRET_KEY>"
158157

159158
##### 上传策略
160159

161-
[uptoken](http://docs.qiniu.com/api/put.html#uploadToken) 实际上是用 AccessKey/SecretKey 进行数字签名的上传策略(`qiniu/rs/PutPolicy`),它控制则整个上传流程的行为。让我们快速过一遍你都能够决策啥:
160+
[uptoken](http://docs.qiniu.com/api/put.html#uploadToken) 实际上是用 AccessKey/SecretKey 进行数字签名的上传策略(`qiniu.rs.PutPolicy`),它控制则整个上传流程的行为。让我们快速过一遍你都能够决策啥:
162161

163162
```{python}
164163
class PutPolicy(object):
@@ -170,6 +169,9 @@ class PutPolicy(object):
170169
returnBody = None
171170
endUser = None
172171
asyncOps = None
172+
173+
def __init__(self, scope):
174+
self.scope = scope
173175
```
174176

175177
* `scope` 限定客户端的权限。如果 `scope` 是 bucket,则客户端只能新增文件到指定的 bucket,不能修改文件。如果 `scope` 为 bucket:key,则客户端可以修改指定的文件。
@@ -216,7 +218,10 @@ class PutExtra(object):
216218
* `params` 是一个字典。[自定义变量](http://docs.qiniu.com/api/put.html#xVariables),key必须以 x: 开头命名,不限个数。可以在 uploadToken 的 callbackBody 选项中求值。
217219
* `mime_type` 表示数据的MimeType。
218220
* `crc32` 待检查的crc32值
219-
* `check_crc` 可选值为0, 1, 2。 `check_crc=0`: 表示不进行 crc32 校验。`check_crc=1`: 对于 put 等同于 `check_crc=2`;对于 put_file 会自动计算 crc32 值。`check_crc == 2`: 表示进行 crc32 校验,且 crc32 值就是上面的 crc32 变量
221+
* `check_crc` 可选值为0, 1, 2。
222+
`check_crc == 0`: 表示不进行 crc32 校验。
223+
`check_crc == 1`: 上传二进制数据时等同于 `check_crc=2`;上传本地文件时会自动计算 crc32 值。
224+
`check_crc == 2`: 表示进行 crc32 校验,且 crc32 值就是上面的 `crc32` 变量
220225

221226
<a name="upload-do"></a>
222227

@@ -281,20 +286,10 @@ qiniu.conf.SECRET_KEY = "<YOUR_APP_SECRET_KEY>"
281286
282287
import qiniu.resumable_io as rio
283288
284-
class ResumableUpload(object):
285-
position = 0
286-
def __init__(self, string_data):
287-
self.data = string_data
288-
289-
def read(self, length):
290-
data = self.data[self.position: self.position+length]
291-
self.position += length
292-
return data
293-
294289
a = "resumable upload string"
295290
extra = rio.PutExtra(bucket_name)
296291
extra.mime_type = "text/plain"
297-
ret, err = rio.put(uptoken, key, ResumableUpload(a), len(a), extra)
292+
ret, err = rio.put(uptoken, key, StringIO.StringIO(a), len(a), extra)
298293
if err is not None:
299294
sys.stderr.write('error: %s ' % err)
300295
return
@@ -365,7 +360,7 @@ private_url = policy.make_request(base_url)
365360

366361
#### 断点续下载
367362

368-
无论是公有资源还是私有资源,获得的下载 url 支持标准的 HTTP 断点续传协议。考虑到多数语言都有相应的断点续下载支持的成熟方法,七牛 C-SDK 并不提供断点续下载相关代码。
363+
无论是公有资源还是私有资源,获得的下载 url 支持标准的 HTTP 断点续传协议。考虑到多数语言都有相应的断点续下载支持的成熟方法,七牛 Python-SDK 并不提供断点续下载相关代码。
369364

370365
<a name="rs"></a>
371366

docs/demo.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,10 @@ def resumable_put():
125125
qiniu.rs.Client().delete(bucket_name, key)
126126

127127
# @gist resumable_put
128-
class ResumableUpload(object):
129-
position = 0
130-
def __init__(self, string_data):
131-
self.data = string_data
132-
133-
def read(self, length):
134-
data = self.data[self.position: self.position+length]
135-
self.position += length
136-
return data
137-
138128
a = "resumable upload string"
139129
extra = rio.PutExtra(bucket_name)
140130
extra.mime_type = "text/plain"
141-
ret, err = rio.put(uptoken, key, ResumableUpload(a), len(a), extra)
131+
ret, err = rio.put(uptoken, key, StringIO.StringIO(a), len(a), extra)
142132
if err is not None:
143133
sys.stderr.write('error: %s ' % err)
144134
return

qiniu/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
ACCESS_KEY = "<access_key>"
4-
SECRET_KEY = "<secret_key>"
3+
ACCESS_KEY = ""
4+
SECRET_KEY = ""
55

66
RS_HOST = "rs.qbox.me"
77
RSF_HOST = "rsf.qbox.me"

qiniu/rs/rs_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class PutPolicy(object):
1515
returnBody = None
1616
endUser = None
1717
asyncOps = None
18-
# @endgist
1918

2019
def __init__(self, scope):
2120
self.scope = scope
21+
# @endgist
2222

2323
def token(self, mac=None):
2424
if mac is None:

0 commit comments

Comments
 (0)