Skip to main content

No project description provided

Project description

https://travis-ci.org/aio-libs/aiobotocore.svg?branch=master https://codecov.io/gh/aio-libs/aiobotocore/branch/master/graph/badge.svg https://img.shields.io/pypi/v/aiobotocore.svg

Async client for amazon services using botocore and aiohttp/asyncio.

Main purpose of this library to support amazon s3 api, but other services should work (may be with minor fixes). For now we have tested only upload/download api for s3, other users report that SQS and Dynamo services work also. More tests coming soon.

Install

$ pip install aiobotocore

Basic Example

import asyncio
import aiobotocore

AWS_ACCESS_KEY_ID = "xxx"
AWS_SECRET_ACCESS_KEY = "xxx"


async def go(loop):
    bucket = 'dataintake'
    filename = 'dummy.bin'
    folder = 'aiobotocore'
    key = '{}/{}'.format(folder, filename)

    session = aiobotocore.get_session(loop=loop)
    client = session.create_client('s3', region_name='us-west-2',
                                   aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
                                   aws_access_key_id=AWS_ACCESS_KEY_ID)
    # upload object to amazon s3
    data = b'\x01'*1024
    resp = await client.put_object(Bucket=bucket,
                                        Key=key,
                                        Body=data)
    print(resp)

    # getting s3 object properties of file we just uploaded
    resp = await client.get_object_acl(Bucket=bucket, Key=key)
    print(resp)

    # delete object from s3
    resp = await client.delete_object(Bucket=bucket, Key=key)
    print(resp)

    # list s3 objects using paginator
    paginator = client.get_paginator('list_objects')
    async for result in paginator.paginate(Bucket=bucket, Prefix=folder):
        for c in result.get('Contents', []):
            print(c)

    # get object from s3
    response = await client.get_object(Bucket=bucket, key=key)
    # this will ensure the connection is correctly re-used/closed
    async with response['Body'] as stream:
        bytes = await stream.read()

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

Run Tests

Make sure you have development requirements installed and your amazon key and secret accessible via environment variables:

$ cd aiobotocore
$ export AWS_ACCESS_KEY_ID=xxx
$ export AWS_SECRET_ACCESS_KEY=xxx
$ pip install -Ur requirements-dev.txt

Execute tests suite:

$ py.test -v tests

Mailing List

https://groups.google.com/forum/#!forum/aio-libs

Requirements

Changes

0.2.0 (2017-01-30)

  • add support for proxies (thanks @jjonek)

  • remove AioConfig verify_ssl connector_arg as this is handled by the create_client verify param

  • remove AioConfig limit connector_arg as this is now handled by by the Config max_pool_connections property (note default is 10)

0.1.1 (2017-01-16)

  • botocore updated to version 1.5.0

0.1.0 (2017-01-12)

  • Pass timeout to aiohttp.request to enforce read_timeout #86 (thanks @vharitonsky) (bumped up to next semantic version due to read_timeout enabling change)

0.0.6 (2016-11-19)

  • Added enforcement of plain response #57 (thanks @rymir)

  • botocore updated to version 1.4.73 #74 (thanks @vas3k)

0.0.5 (2016-06-01)

  • Initial alpha release

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

aiobotocore-0.2.0.tar.gz (16.1 kB view details)

Uploaded Source

File details

Details for the file aiobotocore-0.2.0.tar.gz.

File metadata

  • Download URL: aiobotocore-0.2.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiobotocore-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2ead0be933a414a67e0cf75c050626d6f2690b6615404062615c059bc2b67034
MD5 15cfbdde7f7ec8b52bfcfe14c3c26894
BLAKE2b-256 ce0e4f4181c60c46558bed5ff17c6dee7fb2f94ae79e9579b1fe5ab3aaac5dcf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page