Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A async aliyun OSS library.

Project description

Async aliyun OSS library
=========================

Based on aiohttp and oss2, Require python3.6+

To get an object

.. code-block:: python

result = await bucket.get_object(...

To read the content of object::

body = await result.resp.read()


Install
----------------
.. code-block:: shell
pip install asyncoss


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

.. code-block:: python

import asyncoss

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

auth = asyncoss.Auth('<Your AccessKeyID>', '<Your AccessKeySecret>')

async def main(loop):
# The object key in the bucket is story.txt
async with asyncoss.Bucket(auth, endpoint, '<your bucket name>') as bucket:
key = 'story.txt'

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

# Upload
data = dict(a=1, b=2)
await bucket.put_object(key, json.dumps(data), headers={'Content-Type': 'application/json'})

# Download
result = await bucket.get_object(key)
print(result.headers)
print(await result.resp.read())

# Delete
await bucket.delete_object(key)

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

loop = asyncio.get_event_loop()
loop.run_until_complete(go(main))

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for asyncoss, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size asyncoss-0.0.1.tar.gz (22.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page