Skip to main content

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() and mimetypes.guess_file_type() change signature and location in Python 3.13.
  • ✅ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

guess_file_mime_type-0.1.0a1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

guess_file_mime_type-0.1.0a1-py2.py3-none-any.whl (3.2 kB view details)

Uploaded Python 2Python 3

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

Hashes for guess_file_mime_type-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 44f45fdd80a6960c520297d0ec2c233e670151cb0ed8430cfabf6bc2e7364f48
MD5 b91f1e100183e51d16f0add06f71bf0f
BLAKE2b-256 a6ab8064ad5b45cf32090d148afa91934fb733d19ebf7e5b6616d2f21cafd2ed

See more details on using hashes here.

File details

Details for the file guess_file_mime_type-0.1.0a1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for guess_file_mime_type-0.1.0a1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0fc0e501ccb22bd84f39238953f70b192350f16aba57c8799e2eafda434c089f
MD5 8f2eaab7527978ef0b7415a591a49095
BLAKE2b-256 59ffc42b163d5a1e800259c675b8e30c2d52cd6069beebbe23af655d2e85e2b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page