Skip to content

Allow providing extra DEFAULT_TEXT_MIME_TYPES #275

@georgebv

Description

@georgebv

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprove an existing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions