Skip to main content

Asyncio-based client for S3

Project description

Status:
Alpha

The aio-s3 is a small library for accessing Amazon S3 Service that leverages python’s standard asyncio library.

Only read operations are supported so far, contributions are welcome.

Example

Basically all methods supported so far are shown in this example:

import asyncio

from aios3.bucket import Bucket


@asyncio.coroutine
def main():
    bucket = Bucket('uaprom-logs',
        aws_region='eu-west-1',
        aws_endpoint='s3-eu-west-1.amazonaws.com',
        aws_key='AKIAIOSFODNN7EXAMPLE',
        aws_secret='wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
    # List keys based on prefix
    lst = yield from bu.list('some-prefix')
    response = yield from bu.get(lst[0])
    print(len(response))
    response = yield from bu.download(lst[0])
    print("GOT Response", dir(response))
    while 1:
        chunk = yield from response.read(65536)
        print("Received", len(chunk))
        if not chunk:
            break

asyncio.get_event_loop().run_until_complete(main())

Reference

Bucket(name, *, aws_key, aws_secret, aws_region, aws_endpoint, connector):

Creates a wrapper object for accessing S3 bucket. Note unlike in many other bindings you need to specify aws_region (and probably aws_endpoint) correctly (see a table). The connector is an aiohttp connector, which might be used to setup proxy or other useful things.

Bucket.list(prefix='', max_keys=1000):

Lists items which start with prefix. Each returned item is a Key object. This method is coroutine.

Bucket.get(key):

Fetches object names key. The key might be a string or Key object. Returns bytes. This method is coroutine.

Bucket.download(key):

Allows iteratively download the key. The object returned by the coroutine is an object having method .read(bufsize) which is a coroutine too.

Key

Represents an S3 key returned by Bucket.list. Key has at least the following attributes:

  • key – the full name of the key stored in a bucket

  • last_modifieddatetime.datetime object

  • etag – The ETag, usually md5 of the content with additional quotes

  • size – Size of the object in bytes

  • storage_class – Storage class of the object

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

aio-s3-0.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file aio-s3-0.1.tar.gz.

File metadata

  • Download URL: aio-s3-0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aio-s3-0.1.tar.gz
Algorithm Hash digest
SHA256 b5441738bbe78bbfcb6e20f5928896480784581292b119dd734f8a1e3478fea5
MD5 1e55a5e10e2bf2ee3ae9bb5d3f12261e
BLAKE2b-256 a3591480a21173c55a5d95f1dc5743fb71cd7cb1c0dcd6e8fd7041be87f782bb

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