METADATA 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. Metadata-Version: 2.1
  2. Name: oss2
  3. Version: 2.19.0
  4. Summary: Aliyun OSS (Object Storage Service) SDK
  5. Home-page: http://oss.aliyun.com
  6. Classifier: Development Status :: 5 - Production/Stable
  7. Classifier: Intended Audience :: Developers
  8. Classifier: License :: OSI Approved :: MIT License
  9. Classifier: Operating System :: OS Independent
  10. Classifier: Programming Language :: Python
  11. Classifier: Programming Language :: Python :: 2
  12. Classifier: Programming Language :: Python :: 2.6
  13. Classifier: Programming Language :: Python :: 2.7
  14. Classifier: Programming Language :: Python :: 3
  15. Classifier: Programming Language :: Python :: 3.3
  16. Classifier: Programming Language :: Python :: 3.4
  17. Classifier: Programming Language :: Python :: 3.5
  18. Classifier: Programming Language :: Python :: 3.6
  19. Classifier: Programming Language :: Python :: 3.7
  20. Classifier: Programming Language :: Python :: 3.8
  21. License-File: LICENSE
  22. Requires-Dist: requests !=2.9.0
  23. Requires-Dist: crcmod >=1.7
  24. Requires-Dist: pycryptodome >=3.4.7
  25. Requires-Dist: aliyun-python-sdk-kms >=2.4.1
  26. Requires-Dist: aliyun-python-sdk-core >=2.13.12
  27. Requires-Dist: six
  28. Alibaba Cloud OSS SDK for Python
  29. ================================
  30. .. image:: https://badge.fury.io/py/oss2.svg
  31. :target: https://badge.fury.io/py/oss2
  32. .. image:: https://travis-ci.org/aliyun/aliyun-oss-python-sdk.svg?branch=master
  33. :target: https://travis-ci.org/aliyun/aliyun-oss-python-sdk
  34. .. image:: https://coveralls.io/repos/github/aliyun/aliyun-oss-python-sdk/badge.svg?branch=master
  35. :target: https://coveralls.io/github/aliyun/aliyun-oss-python-sdk?branch=master
  36. `README of Chinese <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/README-CN.rst>`
  37. Overview
  38. --------
  39. Alibaba Cloud Object Storage Python SDK 2.x. This version is not compatible with the previous version (Version 0.x). The package name is `oss2` to avoid conflict with previous versions.
  40. The SDK of this version is dependent on the third-party HTTP library `requests <https://github.com/kennethreitz/requests>`_ and `crcmod`. Install the SDK following the methods below.
  41. Note:
  42. This version does not contain the `osscmd` command line tool.
  43. Running environment
  44. -------------------
  45. Python 2.6(not recommended),2.7,3.3(not recommended),3.4,3.5,3.6
  46. Note:
  47. Python 2.6 is not recommended because it is no longer supported by the Python core team.
  48. Do not use Python 3.3.0 or 3.3.1. Refer to `Python Issue 16658 <https://bugs.python.org/issue16658>`_.
  49. Installing
  50. ----------
  51. Install the official release version through PIP (taking Linux as an example):
  52. .. code-block:: bash
  53. $ pip install oss2
  54. You can also install the unzipped installer package directly:
  55. .. code-block:: bash
  56. $ sudo python setup.py install
  57. Getting started
  58. ---------------
  59. .. code-block:: python
  60. # -*- coding: utf-8 -*-
  61. import oss2
  62. endpoint = 'http://oss-cn-hangzhou.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region.
  63. auth = oss2.Auth('<Your AccessKeyID>', '<Your AccessKeySecret>')
  64. bucket = oss2.Bucket(auth, endpoint, '<your bucket name>')
  65. # The object key in the bucket is story.txt
  66. key = 'story.txt'
  67. # Upload
  68. bucket.put_object(key, 'Ali Baba is a happy youth.')
  69. # Download
  70. bucket.get_object(key).read()
  71. # Delete
  72. bucket.delete_object(key)
  73. # Traverse all objects in the bucket
  74. for object_info in oss2.ObjectIterator(bucket):
  75. print(object_info.key)
  76. For more examples, refer to the code under the "examples" directory.
  77. Handling errors
  78. ---------------
  79. The Python SDK interface will throw an exception in case of an error (see oss2.exceptions sub-module) unless otherwise specified. An example is provided below:
  80. .. code-block:: python
  81. try:
  82. result = bucket.get_object(key)
  83. print(result.read())
  84. except oss2.exceptions.NoSuchKey as e:
  85. print('{0} not found: http_status={1}, request_id={2}'.format(key, e.status, e.request_id))
  86. Setup Logging
  87. ---------------
  88. The following code can set the logging level of 'oss2'.
  89. .. code-block:: python
  90. import logging
  91. logging.getLogger('oss2').setLevel(logging.WARNING)
  92. Testing
  93. -------
  94. First set the required AccessKeyId, AccessKeySecret, endpoint and bucket information for the test through environment variables (**Do not use the bucket for the production environment**).
  95. Take the Linux system for example:
  96. .. code-block:: bash
  97. $ export OSS_TEST_ACCESS_KEY_ID=<AccessKeyId>
  98. $ export OSS_TEST_ACCESS_KEY_SECRET=<AccessKeySecret>
  99. $ export OSS_TEST_ENDPOINT=<endpoint>
  100. $ export OSS_TEST_BUCKET=<bucket>
  101. $ export OSS_TEST_STS_ID=<AccessKeyId for testing STS>
  102. $ export OSS_TEST_STS_KEY=<AccessKeySecret for testing STS>
  103. $ export OSS_TEST_STS_ARN=<Role ARN for testing STS>
  104. Run the test in the following method:
  105. .. code-block:: bash
  106. $ nosetests # First install nose
  107. You can set environment variable to test auth v2:
  108. .. code-block:: bash
  109. $ export OSS_TEST_AUTH_VERSION=v2
  110. More resources
  111. --------------
  112. - `More examples <https://github.com/aliyun/aliyun-oss-python-sdk/tree/master/examples>`_.
  113. - `Python SDK API documentation <http://aliyun-oss-python-sdk.readthedocs.org/en/latest>`_.
  114. - `Official Python SDK documentation <https://help.aliyun.com/document_detail/32026.html>`_.
  115. Contacting us
  116. -------------
  117. - `Alibaba Cloud OSS official website <http://oss.aliyun.com>`_.
  118. - `Alibaba Cloud OSS official forum <http://bbs.aliyun.com>`_.
  119. - `Alibaba Cloud OSS official documentation center <https://help.aliyun.com/document_detail/32026.html>`_.
  120. - Alibaba Cloud official technical support: `Submit a ticket <https://workorder.console.aliyun.com/#/ticket/createIndex>`_.
  121. License
  122. -------
  123. - `MIT <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/LICENSE>`_.