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.2.tar.gz
.
File metadata
- Download URL: asgi-s3-response-middleware-0.0.2.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 | 8d532883dba54d96175e28784c536a21f920518839308e89c4f579d95fa68e04 |
|
MD5 | 2fafb32a24c1736e0e088095deb642a6 |
|
BLAKE2b-256 | fa844bbb00bccfd21f49a5c83801d08a04291661fbf9a63356411cdfb361c5fe |
File details
Details for the file asgi_s3_response_middleware-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: asgi_s3_response_middleware-0.0.2-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 | 2042947e49d197a9fb1654fa04fa2746b271094c85448c020f2433d9eb402596 |
|
MD5 | 37e382ac9e7238c40ac8659100efa7a9 |
|
BLAKE2b-256 | 65b9724cffd62afcca8c7604f43bfc9434cee1dcf66d064b119b3a933419074b |