==========================
.. 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.
Run environment
--------
Python 2.6,2.7,3.3,3.4,3.5
.. note::
Do not use Python 3.3.0 or 3.3.1. Refer to `Python Issue 16658 <https://bugs.python.org/issue16658>`_.
Installation method
--------
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
Quick use
--------
.. 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.
Handle 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))
Test
----
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
More usage
--------
- `More examples can be found <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>`_.
Contact 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>`_.
Code license
--------
For the MIT license, see LICENSE object.
Metadata
Release files for comname 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| comname-0.0.6.tar.gz | 2.6 MB | Without provenance | Details |
Release files / comname-0.0.6.tar.gz
| Download URL | comname-0.0.6.tar.gz |
|---|---|
| Size | 2.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81d7d2c68acf137a310e0fa6ef78c749794d8f415f7d0b2de21423a674670382
|
|
BLAKE2b-256 checksum How to use checksums |
11dba4406e7b24aa71a2013e334d1e1a2968213026c4c7f4b5df96f2b33f875b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.7
|
Security for comname 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.