OpenS3 API

class openS3.utils.OpenS3(bucket, access_key, secret_key)[source]

A context manager for interfacing with S3.

delete()[source]

Remove file from its S3 bucket.

exists()[source]

Return True if file exists in S3 bucket.

md5hash[source]

Return the MD5 hash string of the file content

mimetype[source]

Return mimetype of file. If file does not have a mimetype, make a guess.

read()[source]

Return a bytes object with the contents of the remote S3 object.

Rtype bytes:
size[source]

Return the size of the buffer, in bytes.

url[source]

Return URL of resource

write(content)[source]

Write content to file in S3.

Parameters:content
exception openS3.utils.S3IOError[source]

Generic exception class for S3 communication errors.

openS3.utils.b64_string(byte_string)[source]

Return an base64 encoded byte string as an ENCODING decoded string

openS3.utils.get_valid_filename(string_to_clean)[source]

Returns the given string converted to a string that can be used for a clean filename. Specifically, leading and trailing spaces are removed; other spaces are converted to underscores; and anything that is not a unicode alphanumeric, dash, underscore, or dot, is removed.

>>> get_valid_filename("john's portrait in 2004.jpg")
'johns_portrait_in_2004.jpg'
openS3.utils.strpawstime(timestamp)[source]

Return datetime from parsed AWS header timestamp string. AWS Datetime Format: Wed, 28 Oct 2009 22:32:00 GMT

openS3.utils.validate_values(validation_func, dic)[source]

Validate each value in dic by passing it through func. Raise a ValueError if validation_func does not return True.

Previous topic

Changelog

This Page