s3-storage
Simple and reusable S3 file upload/delete utilities for Python applications.
Works with FastAPI, Flask, Django, or any plain Python project.
Features
- Upload files, images, videos, and documents.
- Async support via thread pool.
- File type and size validation.
- Delete and replace files.
- Works with AWS S3 and S3-compatible services (MinIO, Wasabi, DigitalOcean Spaces, etc.).
- Configurable via environment variables or explicit settings.
Installation
pip install s3-storage
For FastAPI integration:
pip install s3-storage[fastapi]
Configuration
Set the following environment variables:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION_NAME=us-east-1
AWS_BUCKET_NAME=your_bucket_name
AWS_DEFAULT_ACL=public-read # optional
Or create an S3StorageSettings instance manually:
from s3_storage import S3StorageSettings
settings = S3StorageSettings(
access_key_id="your_access_key",
secret_access_key="your_secret_key",
region_name="us-east-1",
bucket_name="your_bucket_name",
default_acl="public-read",
)
Usage
FastAPI example
from fastapi import FastAPI, UploadFile, File
from s3_storage import upload_image_async
app = FastAPI()
@app.post("/upload-avatar")
async def upload_avatar(file: UploadFile = File(...)):
url = await upload_image_async(file, folder="users/avatars")
return {"url": url}
Synchronous example
from s3_storage import upload_file
with open("report.pdf", "rb") as f:
url = upload_file(f, folder="documents", max_size_mb=10)
print(url)
Delete a file
from s3_storage import delete_file_async
await delete_file_async("https://bucket.s3.region.amazonaws.com/users/avatars/old.jpg")
Replace a file
from s3_storage import replace_file
new_url = await replace_file(
old_file_url="https://bucket.s3.region.amazonaws.com/users/avatars/old.jpg",
new_file=new_file,
folder="users/avatars",
)
Upload multiple files
from s3_storage import upload_multiple_async
urls = await upload_multiple_async(files, folder="gallery")
S3-compatible services
For MinIO or similar services:
settings = S3StorageSettings(
access_key_id="minioadmin",
secret_access_key="minioadmin",
region_name="us-east-1",
bucket_name="mybucket",
endpoint_url="http://localhost:9000",
path_style=True,
default_acl="public-read",
)
url = await upload_file_async(file, folder="uploads", settings=settings)
Development
git clone https://github.com/yourusername/s3-storage.git
cd s3-storage
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
Running tests
pytest
License
MIT
Metadata
Release files for s3-storage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| s3_storage-0.1.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| s3_storage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.6 kB
Release files / s3_storage-0.1.0.tar.gz
| Download URL | s3_storage-0.1.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ddc10c0354301d1f3b372659b6373a632e136782785f6ccdbaf5da6cff16d1f
|
|
BLAKE2b-256 checksum How to use checksums |
4a973d8fe89a7057ac347902f8dd1d14e30e06bf666f209e8e44fac61fca0fcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.
Transparency logRelease files / s3_storage-0.1.0-py3-none-any.whl
| Download URL | s3_storage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad309b83f73db07517b8716c36248d62e602aed29db83bc22bd9a9d9a7ab3615
|
|
BLAKE2b-256 checksum How to use checksums |
feac7caaaa97e35f64d0f8fab79069d3dbbefd003ea595ddfa8ace013cbb745a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.
Transparency log