Skip to main content

content-types 🗃️🔎

A Python library to map file extensions to MIME types. It also provides a CLI for quick lookups right from your terminal. If no known mapping is found, the tool returns application/octet-stream.

Unlike other libraries, this one does not try to access the file or parse the bytes of the file or stream. It just looks at the extension which is valuable when you don't have access to the file directly. For example, you know the filename but it is stored in s3 and you don't want to download it just to fully inspect the file.

Installation

uv pip install content-types

Usage

import content_types

# Forward lookup: filename -> MIME type
the_type = content_types.get_content_type("example.jpg")
print(the_type)  # "image/jpeg"

# For very common files, you have shortcuts:
print(f'Content-Type for webp is {content_types.webp}.') 
# Content-Type for webp is image/webp.

CLI

To use the library as a CLI tool, just install it with uv or pipx.

uv tool install content-types

Now it will be available machine-wide.

content-types example.jpg

# Outputs image/jpeg

Contributing

Contributions are welcome! Check out the GitHub repo for more details on how to get involved.

Metadata

Release files for content-types 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for content-types 0.2.2
File Size Uploaded Provenance Actions
content_types-0.2.2.tar.gz 6.9 kB Without provenance Details for content_types-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for content-types 0.2.2
File Interpreter ABI Platform Actions
content_types-0.2.2-py3-none-any.whl Python 3 none any Details for content_types-0.2.2-py3-none-any.whl

Total release size: 12.9 kB

Release files / content_types-0.2.2.tar.gz

Download URL content_types-0.2.2.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f0b7e5960a13285f843ccaf3fb68be81a61699486f0371ffaf360fe868b2265c
BLAKE2b-256 checksum
How to use checksums
0e9c98b14209cd2a4b08e98d81016d15e6469843a6cbf199998667b57e775944
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.25

Release files / content_types-0.2.2-py3-none-any.whl

Download URL content_types-0.2.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
718ff5818d22370ec7d6fef38d97856871a6abbb93098cfdaf3dfedc7b91311e
BLAKE2b-256 checksum
How to use checksums
a3b164084fee02858de6cbea6fd375f947be2fd1d965bbcf5235725abdd1cb2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.25

Security for content-types 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page