Skip to content

Commit ace4a75

Browse files
committed
update demo & docs
1 parent 6b45d10 commit ace4a75

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

docs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ import qiniu.io
262262
extra = qiniu.io.PutExtra()
263263
extra.mime_type = "text/plain"
264264
265-
ret, err = qiniu.io.put(uptoken, key, "hello!", extra)
265+
# data 可以是str或read()able对象
266+
data = StringIO.StringIO("hello!")
267+
ret, err = qiniu.io.put(uptoken, key, data, extra)
266268
if err is not None:
267269
error(err)
268270
return

docs/demo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import os
33
import sys
4+
import StringIO
45

56
# @gist import_io
67
import qiniu.io
@@ -112,7 +113,9 @@ def put_binary():
112113
extra = qiniu.io.PutExtra()
113114
extra.mime_type = "text/plain"
114115

115-
ret, err = qiniu.io.put(uptoken, key, "hello!", extra)
116+
# data 可以是str或read()able对象
117+
data = StringIO.StringIO("hello!")
118+
ret, err = qiniu.io.put(uptoken, key, data, extra)
116119
if err is not None:
117120
error(err)
118121
return

qiniu/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PutExtra(object):
2020
def put(uptoken, key, data, extra=None):
2121
""" put your data to Qiniu
2222
23-
key, your resource key. if key is None, Qiniu will generate one.
23+
If key is None, the server will generate one.
2424
data may be str or read()able object.
2525
"""
2626
fields = {
@@ -55,7 +55,7 @@ def put(uptoken, key, data, extra=None):
5555
def put_file(uptoken, key, localfile, extra=None):
5656
""" put a file to Qiniu
5757
58-
key, your resource key. if key is None, Qiniu will generate one.
58+
If key is None, the server will generate one.
5959
"""
6060
if extra is not None and extra.check_crc == 1:
6161
extra.crc32 = _get_file_crc32(localfile)

0 commit comments

Comments
 (0)