PKG-INFO 5.7 KB

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