METADATA 5.9 KB

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