jordaneremieff / mangum

AWS Lambda support for ASGI applications
https://mangum.io/
MIT License
1.67k stars 119 forks source link

Allow providing extra DEFAULT_TEXT_MIME_TYPES #275

Closed georgebv closed 1 year ago

georgebv commented 1 year ago

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:

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)
jordaneremieff commented 1 year ago

Hi @georgebv, this is similar to a recent issue report in https://github.com/jordaneremieff/mangum/issues/270.

One of the solutions proposed was to re-introduce the text_mime_types configuration, if you are able to put forward a PR to do this, then I will review and merge.

georgebv commented 1 year ago

@jordaneremieff sounds good, I'll link it here once I get to it (~this week). Also, FYI, I am using mangum to deploy a full-blown web app on FastAPI to aws lambda.

jordaneremieff commented 1 year ago

Released in 0.16.0.