Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A Python library that allows you to interact with Amazon S3 Buckets as if they are your local filesystem.

Project description

Platforms like Heroku don’t allow for FUSE filesystem usage, so I had to get a bit creative.

Introducing, s3monkey, a library that mocks out all standard Python library system file operations, allowing you to use already–written code to interface with Amazon S3.

All standard library file operation modules are patched when using the provided context manager, including the built–in open, os, io, & pathlib.

If you’re interested in financially supporting Kenneth Reitz open source, consider visiting this link. Your support helps tremendously with sustainability of motivation, as Open Source is no longer part of my day job.

Potential Use Cases

  • Running Jupyter Notebooks on non-persistient storage (still being worked out).
  • Storing user uploads for Django applications (e.g. the media folder).

Usage

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are expected to be set:

$ AWS_ACCESS_KEY_ID=xxxxxxxxxxx
$ AWS_SECRET_ACCESS_KEY=xxxxxxxxxxx

Basic usage:

from s3monkey import S3FS

with S3FS(bucket='media.kennethreitz.com', mount_point='/app/data') as fs:

    # Create a 'test' key on S3, with the contents of 'hello'.
    with open('/app/data/test', 'w') as f:
        f.write('hello')

    # List the keys in the S3 bucket.
    print(os.listdir('/app/data'))
    # ['file1.txt', 'file2.txt', 'file2.txt', 'test', …]

Installation

$ pipenv install s3monkey

This module only supports Python 3.

Download files

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

Files for s3monkey, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size s3monkey-0.1.1-py2.py3-none-any.whl (69.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size s3monkey-0.1.1.tar.gz (61.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page