Popularity
5.7
Growing
Activity
8.1
Declining
225
5
35

Description

A package for detecting mime types and extensions based on magic numbers

Programming language: Go
Tags: Utilities     Golang     Magic Numbers     File Signature    
Latest version: v1.0.4

mimetype alternatives and similar packages

Based on the "Utilities" category

Do you think we are missing an alternative of mimetype or a related project?

Add another 'Utilities' Package

README

mimetype

A package for detecting MIME types and extensions based on magic numbers No C bindings, zero dependencies and thread safe

Install

go get github.com/gabriel-vasile/mimetype

Usage

There are quick [examples](EXAMPLES.md) and GoDoc for full reference.

Supported MIME types

See [supported mimes](supported_mimes.md) for the list of detected MIME types. If support is needed for a specific file format, please open an issue.

Structure

mimetype uses an hierarchical structure to keep the MIME type detection logic. This reduces the number of calls needed for detecting the file type. The reason behind this choice is that there are file formats used as containers for other file formats. For example, Microsoft Office files are just zip archives, containing specific metadata files. Once a file a file has been identified as a zip, there is no need to check if it is a text file, but it is worth checking if it is an Microsoft Office file.

To prevent loading entire files into memory, when detecting from a reader or from a file mimetype limits itself to reading only the first 3072 bytes from the input.

Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).


*Note that all licence references and agreements mentioned in the mimetype README section above are relevant to that project's source code only.