Middleware to spill large responses over to S3.
Project description
ASGI S3 Response Middleware
Middleware to spill large responses over to S3.
Source Code: https://github.com/developmentseed/asgi-s3-response-middleware
Usage
An ASGI middleware class to automatically push repsonses S3 and instead return a 303 redirect to the object on S3.
This can be useful to avoid hitting limits on the size of API response bodies, such as when working around AWS Lambda's 6MB response limit.
Example
import uuid
import boto3
from fastapi import FastAPI
from asgi_s3_response_middleware import S3ResponseMiddleware
s3_client = boto3.client('s3')
app = FastAPI()
app.add_middleware(
S3ResponseMiddleware,
s3_bucket_name='my-example-bucket',
s3_client=s3_client,
key_generator=lambda: f"responses/{uuid.uuid4()}",
size_threshold=2 * 1024**2, # 2MB
url_expiry=30, # 30 seconds
)
Development
Releases
Releases are managed via CICD workflow, as described in the Python Packaging User Guide. To create a new release:
- Update the version in
src/asgi_s3_response_middleware/__init__.py
following appropriate Semantic Versioning convention. - Push a tagged commit to
main
, with the tag matching the package's new version number.
[!NOTE]
This package makes use of Github's automatically generated release notes. These can be later augmented if one sees fit.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file asgi-s3-response-middleware-0.0.3.tar.gz
.
File metadata
- Download URL: asgi-s3-response-middleware-0.0.3.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f748043bf510f52e2c84cd6a2afc94c0020e8ed00b59ecd255478607ee0b5538 |
|
MD5 | 5a2f3b06605cc05e05981b6cf136be51 |
|
BLAKE2b-256 | 8bc5f510d6056d969640ef53115977b1de7621301e36639a015255b1c952d664 |
File details
Details for the file asgi_s3_response_middleware-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: asgi_s3_response_middleware-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2933626bd869d7e1ce9f073873801240ebb76136bd4fb7c15ba3840398d42fdf |
|
MD5 | 2bfdf873e1220c46b65b9cd2a55d0c16 |
|
BLAKE2b-256 | 09d66459d4813deb93c22c9fc68a49f05918488fa85123fffc16e1b4e32d8a93 |