Doozer-S3

Doozer-S3 is a library that helps to easily interact with S3 from inside a Doozer application.

Installation

Doozer-S3 can be installed with:

$ python -m pip install Doozer-S3

Warning

Doozer-S3 is not yet available on the Python Package Index.

Configuration

The following configuration settings can be added to the application.

AWS_ACCESS_KEY_ID The Access ID used to identify the account. Defaults to None.
AWS_SECRET_ACCESS_KEY The Access Secret used to identify the account. Defaults to None.
AWS_BUCKET_NAME The name of the default bucket to use. Defaults to None.
AWS_REGION_NAME The name of the Region where the bucket is located. Defaults to None.

Usage

from doozer import Application
from doozer_s3 import S3

app = Application('application-with-s3')
app.settings['AWS_BUCKET_NAME'] = 'my-doozer-bucket'

S3(app)

API

class doozer_s3.S3(app=None)[source]

A class to interact with S3.

check(key, *, bucket=None)[source]

Check to see if a file exists in an S3 bucket.

Parameters:
  • key (str) – The name of the file for which to check.
  • bucket (Optional[str]) – THe name of the bucket in which to check for the file. If no value is provided, the AWS_BUCKET_NAME setting will be used.
Returns:

True if the file exists.

Return type:

bool

Raises:

ValueError – If no bucket name is specified.

download(key, *, bucket=None)[source]

Return the contents of a file in an S3 bucket.

Parameters:
  • key (str) – The name of the file to download.
  • bucket (Optional[str]) – The name of the bucket from which to download the file. If no value is provided, the AWS_BUCKET_NAME setting will be used.
Returns:

The contents of the file.

Return type:

bytes

Raises:
init_app(app)[source]

Initialize an Application instance.

Parameters:app (doozer.base.Application) – The application instance to be initialized.
upload(key, file, *, bucket=None)[source]

Upload a file to an S3 bucket.

Parameters:
  • key (str) – The name of the file to upload.
  • file (bytes) – The contents of the file.
  • bucket (Optional[str]) – The name of the bucket to which to upload the file. If no value is provided, the AWS_BUCKET_NAME setting will be used.
Raises:

ValueError – If no bucket name is specified.

Contents:

Indices and tables