oss2


Nameoss2 JSON
Version 2.19.1 PyPI version JSON
download
home_pagehttp://oss.aliyun.com
SummaryAliyun OSS (Object Storage Service) SDK
upload_time2024-10-25 11:37:46
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Alibaba Cloud OSS SDK for Python
================================

.. image:: https://badge.fury.io/py/oss2.svg
    :target: https://badge.fury.io/py/oss2
.. image:: https://travis-ci.org/aliyun/aliyun-oss-python-sdk.svg?branch=master
    :target: https://travis-ci.org/aliyun/aliyun-oss-python-sdk
.. image:: https://coveralls.io/repos/github/aliyun/aliyun-oss-python-sdk/badge.svg?branch=master
    :target: https://coveralls.io/github/aliyun/aliyun-oss-python-sdk?branch=master

`README of Chinese <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/README-CN.rst>`

Overview
--------

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. 


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. 

Note:

    This version does not contain the `osscmd` command line tool. 

Running environment
-------------------

Python 2.6(not recommended),2.7,3.3(not recommended),3.4,3.5,3.6


Note:
    Python 2.6 is not recommended because it is no longer supported by the Python core team. 
    Do not use Python 3.3.0 or 3.3.1. Refer to `Python Issue 16658 <https://bugs.python.org/issue16658>`_.

Installing
----------

Install the official release version through PIP (taking Linux as an example): 

.. code-block:: bash

    $ pip install oss2

You can also install the unzipped installer package directly: 

.. code-block:: bash

    $ sudo python setup.py install


Getting started
---------------

.. code-block:: python

    # -*- coding: utf-8 -*-

    import oss2

    endpoint = 'http://oss-cn-hangzhou.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region. 

    auth = oss2.Auth('<Your AccessKeyID>', '<Your AccessKeySecret>')
    bucket = oss2.Bucket(auth, endpoint, '<your bucket name>')

    # The object key in the bucket is story.txt
    key = 'story.txt'

    # Upload
    bucket.put_object(key, 'Ali Baba is a happy youth.')

    # Download
    bucket.get_object(key).read()

    # Delete
    bucket.delete_object(key)

    # Traverse all objects in the bucket
    for object_info in oss2.ObjectIterator(bucket):
        print(object_info.key)

For more examples, refer to the code under the "examples" directory. 

Handling errors
---------------

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:

.. code-block:: python

    try:
        result = bucket.get_object(key)
        print(result.read())
    except oss2.exceptions.NoSuchKey as e:
        print('{0} not found: http_status={1}, request_id={2}'.format(key, e.status, e.request_id))

Setup Logging
---------------

The following code can set the logging level of 'oss2'.
 .. code-block:: python

    import logging
    logging.getLogger('oss2').setLevel(logging.WARNING)

Testing
-------

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**). 
Take the Linux system for example: 

.. code-block:: bash

    $ export OSS_TEST_ACCESS_KEY_ID=<AccessKeyId>
    $ export OSS_TEST_ACCESS_KEY_SECRET=<AccessKeySecret>
    $ export OSS_TEST_ENDPOINT=<endpoint>
    $ export OSS_TEST_BUCKET=<bucket>

    $ export OSS_TEST_STS_ID=<AccessKeyId for testing STS>
    $ export OSS_TEST_STS_KEY=<AccessKeySecret for testing STS>
    $ export OSS_TEST_STS_ARN=<Role ARN for testing STS>


Run the test in the following method: 

.. code-block:: bash

    $ nosetests                          # First install nose


You can set environment variable to test auth v2:

.. code-block:: bash

    $ export OSS_TEST_AUTH_VERSION=v2

More resources
--------------
- `More examples <https://github.com/aliyun/aliyun-oss-python-sdk/tree/master/examples>`_. 
- `Python SDK API documentation <http://aliyun-oss-python-sdk.readthedocs.org/en/latest>`_. 
- `Official Python SDK documentation <https://help.aliyun.com/document_detail/32026.html>`_.

Contacting us
-------------
- `Alibaba Cloud OSS official website <http://oss.aliyun.com>`_.
- `Alibaba Cloud OSS official forum <http://bbs.aliyun.com>`_.
- `Alibaba Cloud OSS official documentation center <https://help.aliyun.com/document_detail/32026.html>`_.
- Alibaba Cloud official technical support: `Submit a ticket <https://workorder.console.aliyun.com/#/ticket/createIndex>`_.

License
-------
- `MIT <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/LICENSE>`_.

            

Raw data

            {
    "_id": null,
    "home_page": "http://oss.aliyun.com",
    "name": "oss2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/df/b5/f2cb1950dda46ac2284d6c950489fdacd0e743c2d79a347924d3cc44b86f/oss2-2.19.1.tar.gz",
    "platform": null,
    "description": "Alibaba Cloud OSS SDK for Python\r\n================================\r\n\r\n.. image:: https://badge.fury.io/py/oss2.svg\r\n    :target: https://badge.fury.io/py/oss2\r\n.. image:: https://travis-ci.org/aliyun/aliyun-oss-python-sdk.svg?branch=master\r\n    :target: https://travis-ci.org/aliyun/aliyun-oss-python-sdk\r\n.. image:: https://coveralls.io/repos/github/aliyun/aliyun-oss-python-sdk/badge.svg?branch=master\r\n    :target: https://coveralls.io/github/aliyun/aliyun-oss-python-sdk?branch=master\r\n\r\n`README of Chinese <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/README-CN.rst>`\r\n\r\nOverview\r\n--------\r\n\r\nAlibaba 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. \r\n\r\n\r\nThe 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. \r\n\r\nNote:\r\n\r\n    This version does not contain the `osscmd` command line tool. \r\n\r\nRunning environment\r\n-------------------\r\n\r\nPython 2.6(not recommended)\uff0c2.7\uff0c3.3(not recommended)\uff0c3.4\uff0c3.5\uff0c3.6\r\n\r\n\r\nNote:\r\n    Python 2.6 is not recommended because it is no longer supported by the Python core team. \r\n    Do not use Python 3.3.0 or 3.3.1. Refer to `Python Issue 16658 <https://bugs.python.org/issue16658>`_.\r\n\r\nInstalling\r\n----------\r\n\r\nInstall the official release version through PIP (taking Linux as an example): \r\n\r\n.. code-block:: bash\r\n\r\n    $ pip install oss2\r\n\r\nYou can also install the unzipped installer package directly: \r\n\r\n.. code-block:: bash\r\n\r\n    $ sudo python setup.py install\r\n\r\n\r\nGetting started\r\n---------------\r\n\r\n.. code-block:: python\r\n\r\n    # -*- coding: utf-8 -*-\r\n\r\n    import oss2\r\n\r\n    endpoint = 'http://oss-cn-hangzhou.aliyuncs.com' # Suppose that your bucket is in the Hangzhou region. \r\n\r\n    auth = oss2.Auth('<Your AccessKeyID>', '<Your AccessKeySecret>')\r\n    bucket = oss2.Bucket(auth, endpoint, '<your bucket name>')\r\n\r\n    # The object key in the bucket is story.txt\r\n    key = 'story.txt'\r\n\r\n    # Upload\r\n    bucket.put_object(key, 'Ali Baba is a happy youth.')\r\n\r\n    # Download\r\n    bucket.get_object(key).read()\r\n\r\n    # Delete\r\n    bucket.delete_object(key)\r\n\r\n    # Traverse all objects in the bucket\r\n    for object_info in oss2.ObjectIterator(bucket):\r\n        print(object_info.key)\r\n\r\nFor more examples, refer to the code under the \"examples\" directory. \r\n\r\nHandling errors\r\n---------------\r\n\r\nThe 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:\r\n\r\n.. code-block:: python\r\n\r\n    try:\r\n        result = bucket.get_object(key)\r\n        print(result.read())\r\n    except oss2.exceptions.NoSuchKey as e:\r\n        print('{0} not found: http_status={1}, request_id={2}'.format(key, e.status, e.request_id))\r\n\r\nSetup Logging\r\n---------------\r\n\r\nThe following code can set the logging level of 'oss2'.\r\n .. code-block:: python\r\n\r\n    import logging\r\n    logging.getLogger('oss2').setLevel(logging.WARNING)\r\n\r\nTesting\r\n-------\r\n\r\nFirst set the required AccessKeyId, AccessKeySecret, endpoint and bucket information for the test through environment variables (**Do not use the bucket for the production environment**). \r\nTake the Linux system for example: \r\n\r\n.. code-block:: bash\r\n\r\n    $ export OSS_TEST_ACCESS_KEY_ID=<AccessKeyId>\r\n    $ export OSS_TEST_ACCESS_KEY_SECRET=<AccessKeySecret>\r\n    $ export OSS_TEST_ENDPOINT=<endpoint>\r\n    $ export OSS_TEST_BUCKET=<bucket>\r\n\r\n    $ export OSS_TEST_STS_ID=<AccessKeyId for testing STS>\r\n    $ export OSS_TEST_STS_KEY=<AccessKeySecret for testing STS>\r\n    $ export OSS_TEST_STS_ARN=<Role ARN for testing STS>\r\n\r\n\r\nRun the test in the following method: \r\n\r\n.. code-block:: bash\r\n\r\n    $ nosetests                          # First install nose\r\n\r\n\r\nYou can set environment variable to test auth v2:\r\n\r\n.. code-block:: bash\r\n\r\n    $ export OSS_TEST_AUTH_VERSION=v2\r\n\r\nMore resources\r\n--------------\r\n- `More examples <https://github.com/aliyun/aliyun-oss-python-sdk/tree/master/examples>`_. \r\n- `Python SDK API documentation <http://aliyun-oss-python-sdk.readthedocs.org/en/latest>`_. \r\n- `Official Python SDK documentation <https://help.aliyun.com/document_detail/32026.html>`_.\r\n\r\nContacting us\r\n-------------\r\n- `Alibaba Cloud OSS official website <http://oss.aliyun.com>`_.\r\n- `Alibaba Cloud OSS official forum <http://bbs.aliyun.com>`_.\r\n- `Alibaba Cloud OSS official documentation center <https://help.aliyun.com/document_detail/32026.html>`_.\r\n- Alibaba Cloud official technical support: `Submit a ticket <https://workorder.console.aliyun.com/#/ticket/createIndex>`_.\r\n\r\nLicense\r\n-------\r\n- `MIT <https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/LICENSE>`_.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Aliyun OSS (Object Storage Service) SDK",
    "version": "2.19.1",
    "project_urls": {
        "Homepage": "http://oss.aliyun.com"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dfb5f2cb1950dda46ac2284d6c950489fdacd0e743c2d79a347924d3cc44b86f",
                "md5": "3501df7db8f700452b96d2fe950d9bbd",
                "sha256": "a8ab9ee7eb99e88a7e1382edc6ea641d219d585a7e074e3776e9dec9473e59c1"
            },
            "downloads": -1,
            "filename": "oss2-2.19.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3501df7db8f700452b96d2fe950d9bbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 298845,
            "upload_time": "2024-10-25T11:37:46",
            "upload_time_iso_8601": "2024-10-25T11:37:46.638745Z",
            "url": "https://files.pythonhosted.org/packages/df/b5/f2cb1950dda46ac2284d6c950489fdacd0e743c2d79a347924d3cc44b86f/oss2-2.19.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-25 11:37:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "oss2"
}
        
Elapsed time: 0.89856s