aliyun oss sdk for python async
Project description
ossx
ossx is an Aliyun OSS SDK for Python Asyncio.
You are free to extend this project, but it's recommended to always run the unit tests to ensure the existing functionality works as expected.
Implementation Details
ossx uses httpx
as the asynchronous http client, and makes the greatest effort to reuse oss2
code. Therefore, the code of ossx itself is very small, and in addition, ossx also adds type annotations for public methods.
From the user's perspective, the use of ossx and oss2 should be very similar, in most cases you only need to add an await
. Only when streaming reading Object, you need to call await obj.read()
or asynchronous iteration async for chunk in obj
.
Please note, this library will monkey patch a small number of functions in the oss2 library, usually we believe this will not affect the independent use of the oss2 library, for details please see ossx/patch.py
.
Compatibility
Starting from version 2.18.4, ossx will synchronize with the version numbers of the official Aliyun SDK in subsequent releases. When releasing new versions, OSSX will strive to achieve forward compatibility as much as possible. Currently, we guarantee that a minor version of OSSX can be compatible with lower versions of oss2.
It is recommended to keep the version numbers of ossx and oss2 consistent to reduce compatibility issues.
Getting Started
Installation
pip install ossx
Usage
import asyncio
from oss2 import Auth, models
from ossx import AsyncBucket
async def main():
bucket = AsyncBucket(
auth=Auth('your-access-key-id', 'your-access-key-secret'),
endpoint='oss-cn-beijing.aliyuncs.com',
bucket_name='your-bucket-name'
)
content = b'Hello, ossx!'
await bucket.put_object('your-object-key', content)
obj = await bucket.get_object('your-object-key')
assert isinstance(obj, models.GetObjectResult)
assert await obj.read() == content
assert await obj.read() == b''
if __name__ == '__main__':
asyncio.run(main())
You can find the API use cases currently supported in the tests
directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ossx-2.18.6.tar.gz
.
File metadata
- Download URL: ossx-2.18.6.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71008d13d8cef313eebdbd006e13242bd03e85c278dbc62792b5f27df48f268a |
|
MD5 | 1f8e5fa1bdc823d5dcfb2451bc526fb2 |
|
BLAKE2b-256 | a2f636e25089ee2994ac9a88d2755f5d5b6ccfb0012d0ca45f3406e840ac4f3a |
File details
Details for the file ossx-2.18.6-py3-none-any.whl
.
File metadata
- Download URL: ossx-2.18.6-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d362cefd3276cd624b2f8fb1a44fb2ae914a8005d453f8ac899f4fe1c8bdc3a |
|
MD5 | 8568834f751a63011d3ba8262ff1a25a |
|
BLAKE2b-256 | bec00fb4bd2e8c886875458237c035f7f8b7dfce2bf839013c7ff1d77b4b85d5 |