Skip to content

Commit

Permalink
Merge pull request #27 from aliyun/con-multipart
Browse files Browse the repository at this point in the history
add resumable_download
  • Loading branch information
yami committed Mar 25, 2016
2 parents 58e00c1 + 9eb0440 commit 4b1456e
Show file tree
Hide file tree
Showing 12 changed files with 1,013 additions and 169 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ python:
- 3.4
- 3.5
install:
- pip install requests mock nose nose-cov python-coveralls aliyun-python-sdk-sts
- pip install requests nose nose-cov python-coveralls aliyun-python-sdk-sts
- pip install --upgrade mock
script:
- nosetests unittests/ --with-cov
- if [ -n "$OSS_TEST_ACCESS_KEY_ID" ]; then nosetests tests/ --with-cov; fi
Expand Down
8 changes: 5 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ Python SDK的版本号遵循 `Semantic Versioning <http://semver.org/>`_ 规则
Version 2.1.0
-------------

- 增加:可以通过 `defaults.connection_pool_size` 来设置连接池的最大连接数。
- 增加:可以通过 `resumable_upload` 函数的 `num_threads` 参数指定并发的线程数,来进行并发上传。
- 修复:修复一些文档的Bug
- 增加:可以通过 `oss2.defaults.connection_pool_size` 来设置连接池的最大连接数。
- 增加:可以通过 `oss2.resumable_upload` 函数的 `num_threads` 参数指定并发的线程数,来进行并发上传。
- 增加:提供断点下载函数 `oss2.resumable_download` 。
- 修复:保存断点信息的文件名应该由“规则化”的本地文件名生成;当断点信息文件格式不是json时,删除断点信息文件。
- 修复:修复一些文档的Bug。

Version 2.0.6
-------------
Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ Python 2.6,2.7,3.3,3.4,3.5
$ export OSS_TEST_STS_ARN=<Role ARN for testing STS>
然后通过以下方式之一运行测试
然后通过以下方式运行测试

.. code-block:: bash
$ python -m unittest discover tests # 如果Python版本 >= 2.7
$ nosetests # 如果安装了nose
$ nosetests # 请先安装nose
更多使用
--------
Expand Down
6 changes: 3 additions & 3 deletions doc/easy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
.. autoclass:: oss2.PartIterator


断点续传上传
~~~~~~~~~~~~
断点续传(上传、下载)
~~~~~~~~~~~~~~~~~~~

.. autofunction:: oss2.resumable_upload

.. autofunction:: oss2.resumable_download

FileObject适配器
~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 3 additions & 1 deletion oss2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
MultipartUploadIterator, ObjectUploadIterator, PartIterator)


from .resumable import resumable_upload, ResumableStore, determine_part_size
from .resumable import resumable_upload, resumable_download, ResumableStore, ResumableDownloadStore, determine_part_size
from .resumable import make_upload_store, make_download_store


from .compat import to_bytes, to_string, to_unicode, urlparse, urlquote, urlunquote

Expand Down
12 changes: 11 additions & 1 deletion oss2/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ def get(value, default_value):


#: 每个Session连接池大小
connection_pool_size = 10
connection_pool_size = 10


#: 对于断点下载,如果OSS文件大小大于该值就进行并行下载(multiget)
multiget_threshold = 100 * 1024 * 1024

#: 并行下载(multiget)缺省线程数
multiget_num_threads = 4

#: 并行下载(multiget)的缺省分片大小
multiget_part_size = 10 * 1024 * 1024
17 changes: 14 additions & 3 deletions oss2/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@ def __init__(self, status, headers, body, details):
self.message = self.details.get('Message', '')

def __str__(self):
return str(self.details)
error = {'status': self.status,
'details': self.details}
return str(error)


class ClientError(OssError):
def __init__(self, message):
OssError.__init__(self, OSS_CLIENT_ERROR_STATUS, {}, 'ClientError: ' + message, {})

def __str__(self):
return self.body
error = {'status': self.status,
'details': self.body}
return str(error)


class RequestError(OssError):
Expand All @@ -61,7 +65,9 @@ def __init__(self, e):
self.exception = e

def __str__(self):
return self.body
error = {'status': self.status,
'details': self.body}
return str(error)


class ServerError(OssError):
Expand Down Expand Up @@ -147,6 +153,11 @@ class ObjectNotAppendable(Conflict):
code = 'ObjectNotAppendable'


class PreconditionFailed(ServerError):
status = 412
code = 'PreconditionFailed'


class NotModified(ServerError):
status = 304
code = ''
Expand Down
Loading

0 comments on commit 4b1456e

Please sign in to comment.