异步阿里云OSS库。
aiooss的Python项目详细描述
Based on https://github.com/aliyun/aliyun-oss-python-sdk
文档参考官方文档, 调用io操作的接口前加await即可
result=awaitbucket.get_object(...
获取返回内容:
body = await result.resp.read()
Getting started
# -*- coding: utf-8 -*-importaioossendpoint='http://oss-cn-hangzhou.aliyuncs.com'# Suppose that your bucket is in the Hangzhou region.auth=aiooss.Auth('<Your AccessKeyID>','<Your AccessKeySecret>')asyncdefgo(loop):# The object key in the bucket is story.txtasyncwithaiooss.Bucket(auth,endpoint,'<your bucket name>')asbucket:key='story.txt'# Uploadawaitbucket.put_object(key,'Ali Baba is a happy youth.')# Uploaddata=dict(a=1,b=2)awaitbucket.put_object(key,json.dumps(data),headers={'Content-Type':'application/json'})# Downloadresult=awaitbucket.get_object(key)print(result.headers)print(awaitresult.resp.read())# Deleteawaitbucket.delete_object(key)# Traverse all objects in the bucketasyncforobject_infoinaiooss.ObjectIterator(bucket):print(object_info.key)loop=asyncio.get_event_loop()loop.run_until_complete(go(loop))