Fast MIME type mapping library for the .NET ecosystem. Supports almost any Core and Framework version, including netstandard1.2, net40, and net8.0. Extensively tested, focused on performance, and working out of the box. Get your MIME type or extension and be done with it fast. The mapping is zero-config by default and sourced from authoritative sources, such as IANA, and MimeType. About 2,000 extensions and MIME types are mapped. MimeTypeCore builds upon MimeTypeMap.
Install the package:
Get MIME type from an extension, or vice versa:
⭐ That's it! Please consider starring this repository if you find it helpful.
Sometimes, one extension can have multiple MIME types associated. For example, .ts might be text/typescript, or video/mpeg (ts stands for Transport Stream in this case). To resolve the collision, provide Stream to the file, so the header can be sampled for a known sequence of magic bytes:
When dealing with user-provided files, whether from Blazor or MVC, your input is likely to be IBrowserFile or IFormFile. These streams don't support synchronous reading, use MimeTypeMap.TryGetMimeTypeAsync:
To contribute, check the mapping file for the hardcoded mappings, and add new entries. Please follow the code style and alphabetical ordering. Magic headers can be contributed to this file. If you are touching anything beyond that, provide relevant test cases. Thank you.
This library is licensed under the MIT license. 💜
.png)

