An asynchronous python client SDK for OSS(Aliyun Object Storage Service).
It has been verified and used in the production environment with QPS ≈ 500 for about half a year, so you can use it with confidence.
Installation
PyPI (recommend)
$ pip install asyncio-oss
Local compilation
$ git clone git@github.com:Yaocool/async-oss.git
$ python setup.py bdist_wheel
$ pip install ./dist/asyncio_oss-*-py3-none-any.whl
Examples
For more examples, please refer to the test directory.
import logging
import asyncio_oss
import asyncio
import oss2
OSS_ENDPOINT = 'https://oss-cn-hangzhou.aliyuncs.com'
OSS_KEY = '<Your AccessKeyID>'
OSS_SECRET = '<Your AccessKeySecret>'
OSS_AUTH = oss2.Auth(OSS_KEY, OSS_SECRET)
BUCKET_NAME = '<your bucket name>'
OBJECT_KEY = '<your object key>'
async def main():
async with asyncio_oss.Bucket(OSS_AUTH, OSS_ENDPOINT, BUCKET_NAME) as bucket:
await bucket.put_object(OBJECT_KEY, b'your bytes data')
result = await bucket.get_object(OBJECT_KEY)
await result.read()
head_res = await bucket.head_object(OBJECT_KEY)
print(head_res.content_length)
for obj in (await bucket.list_objects()).object_list:
print(obj.key)
await bucket.delete_object(OBJECT_KEY)
if __name__ == '__main__':
log_file_path = "example_logfile.log"
asyncio_oss.set_file_logger(log_file_path, 'asyncio_oss', logging.DEBUG)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Contributors Wall
Discussions Or Issues
Any questions can be raised in Discussions
or Issues
, I will answer them from time to time.