skip to navigation
skip to content

Not Logged In

python-s3file 1.3

Read and write to Amazon S3 using a file-like object

Read and write files to S3 using a file-like object. Refer to S3 buckets and keys using full URLs.

The underlying mechanism is a lazy read and write using cStringIO as the file emulation. This is an in memory buffer so is not suitable for large files (larger than your memory).

As S3 only supports reads and writes of the whole key, the S3 key will be read in its entirety and written on close. Starting from release 1.2 this read and write are deferred until required and the key is only read from if the file is read from or written within and only updated if a write operation has been carried out on the buffer contents.

More tests and docs are needed.




Basic usage:

from s3file import s3open

f = s3open("")
f.write("Lorem ipsum dolor sit amet...")

with statement:

with s3open(path) as remote_file:
    remote_file.write("blah blah blah")

S3 authentication key and secret may be passed into the s3open method or stored in the boto config file.:

f = s3open("", key, secret)

Other parameters to s3open include:

Sets the number of days that the remote file should be cached by clients. Default is 0, not cached.
If True, sets the file to be private. Defaults to False, publicly readable.
The content_type of the file will be guessed from the URL, but you can explicitly set it by passing a content_type value.
New in version 1.1 If False, assume bucket exists and bypass validation. Riskier, but can speed up writing. Defaults to True.
File Type Py Version Uploaded on Size
python-s3file-1.3.tar.gz (md5) Source 2014-02-03 5KB
  • Downloads (All Versions):
  • 13 downloads in the last day
  • 106 downloads in the last week
  • 445 downloads in the last month