Skip to content

fduseless/fast-mime

Repository files navigation

Fast MIME

Support Rails/Marcel style MIME for Python.

It uses Apache Tike's rule.

It's customizable.

Install

pip install fast-mime

Usage

Detect MIME

from fast_mime import MIME
with open("a.pdf", "rb") as fi:
    # detect an opened file
    mime = MIME(fi, name="a.pdf", declared_type="application/pdf", extension=".pdf")
    # all parameters are optional

# detect an unopenned file
mime = MIME("a.pdf", declared_type="application/pdf", extension=".pdf")

# detect without any hint
mime = MIME("a")

Customize MIME rules

from fast_mime import Mime

# define your own mime rule
MIME = Mime.from_xmls(your_rule_file_name)

Patch MIME

class MyMime(Mime):
    def _patch(self):
        super()._patch()
        ...

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages