A Python package that exposes a consistent API for working with different storage backends.
WARNING: This is still under active development.
I needed something that does not depend on Django but exposes a similar
interface to Django's base storage in django.core.files.storage.base.Storage
.
So, if you're using Django: use Django and django-storages instead.
Currently, this package only does the bare minimum that I need it for so
if you're looking for something more full-featured perhaps look at the
cloudstorage package.
- Filesystem.
- Amazon S3.
-
Install the package:
pip install python-file-storage
-
Add your configuration. Set the following as environment variables or add them to a
.env
file in the root of your project:DEFAULT_STORAGE_BACKEND = storage.backends.s3.S3Storage S3_BUCKET_NAME = my-bucket-name S3_ENDPOINT_URL = example.com # Optional S3_ACCESS_KEY_ID = 123 S3_SECRET_ACCESS_KEY = 123
Currently, using more than one storage backend at a time is unsupported.
-
Import
default_storage
and start using the package:from storage import default_storage default_storage.save('example.txt', 'Content') file = default_storage.open('example.txt', 'Content')
- Python 3.8+
- Django is unsupported.
This project follows semantic versioning (SemVer).