A minimal, cross-platform, and cross-version utility to safely guess a file's MIME type.
Project description
guess-file-mime-type
A minimal, cross-platform, and cross-version utility to safely guess a file's MIME type.
Features
- ✅ NT & POSIX filesystem support
- ✅ Uniform API for different Python versions (2+ and 3.0 - 3.13+)
- Standard library functions like
mimetypes.guess_type()andmimetypes.guess_file_type()change signature and location in Python 3.13.
- Standard library functions like
- ✅ Returns sensible default (
application/octet-stream) for unknown types
Why?
- Write portable code that works everywhere, forever.
Installation
pip install guess-file-mime-type
Usage
# coding=utf-8
from __future__ import print_function
from guess_file_mime_type import guess_file_mime_type
mime_type = guess_file_mime_type('/path/to/image.png')
print(mime_type) # 'image/png'
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file guess_file_mime_type-0.1.0a1.tar.gz.
File metadata
- Download URL: guess_file_mime_type-0.1.0a1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44f45fdd80a6960c520297d0ec2c233e670151cb0ed8430cfabf6bc2e7364f48
|
|
| MD5 |
b91f1e100183e51d16f0add06f71bf0f
|
|
| BLAKE2b-256 |
a6ab8064ad5b45cf32090d148afa91934fb733d19ebf7e5b6616d2f21cafd2ed
|
File details
Details for the file guess_file_mime_type-0.1.0a1-py2.py3-none-any.whl.
File metadata
- Download URL: guess_file_mime_type-0.1.0a1-py2.py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fc0e501ccb22bd84f39238953f70b192350f16aba57c8799e2eafda434c089f
|
|
| MD5 |
8f2eaab7527978ef0b7415a591a49095
|
|
| BLAKE2b-256 |
59ffc42b163d5a1e800259c675b8e30c2d52cd6069beebbe23af655d2e85e2b6
|