Issue: I want to serve binary files as is (not base64 encoded)
Cause: everything not in DEFAULT_TEXT_MIME_TYPES is base64 encoded by default
Proposed solution: allow providing additional mime types; suggested options:
- when declaring the handler
Mangum(app, extra_text_mime_types=["image/png"])
- after declaring the handler
handler.add_text_mime_types(["image/png"])
This is my current hacky solution to serve png images:
from mangum import Mangum
from mangum.handlers.utils import DEFAULT_TEXT_MIME_TYPES
from app.main import app
# Monkey patch MIME types
DEFAULT_TEXT_MIME_TYPES.extend(
[
"image/png",
]
)
handler = Mangum(app)
Issue: I want to serve binary files as is (not base64 encoded)
Cause: everything not in
DEFAULT_TEXT_MIME_TYPESis base64 encoded by defaultProposed solution: allow providing additional mime types; suggested options:
Mangum(app, extra_text_mime_types=["image/png"])handler.add_text_mime_types(["image/png"])This is my current hacky solution to serve png images: