Python AWS S3

Creating an AWS S3 connection in Dashboard allows one to store, read or delete messages in the connection's buckets.

Creating key/value pairs in S3 buckets

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class MyService(Service):
    def handle(self):
        with self.cloud.aws.s3.get('My Connection').conn.client() as client:

            # Create a key/value pair under a selected bucket
            key = 'My sample key'
            value = 'My value'
            bucket = 'skiaguuiagscauisgcqiuwxnilhqw'

            # Call S3 with the input
            client.set(key, value, bucket)

And now in the AWS console:

Accessing Boto

The underlying Python library is Boto - it is always available under the client's .impl attribute and lets one access every feature that S3 supports, for instance:

# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class MyService(Service):
    def handle(self):
        with self.cloud.aws.s3.get('My Connection').conn.client() as client:

            # List all buckets
            self.logger.info(client.impl.get_all_buckets())

            # User ID
            self.logger.info(client.impl.get_canonical_user_id())
INFO - [<Bucket: skiaguuiagscauisgcqiuwxnilhqw>]
INFO - 5699349a708b4bfa9790e8f6f5c5163cd6e3511dcf5b48c3a15814c05cf736d9