/MimeTypes

.NET Library that supports working with Internet Media Types ("MIME Types")

Primary LanguageC#MIT LicenseMIT

FolkerKinzel.MimeTypes

NuGet GitHub

.NET Library that supports working with Internet Media Types ("MIME Types")

Project Reference

  • The static MimeString class works on strings and allows to convert file names into Internet Media Types ("MIME types") or Internet Media Types into appropriate file type extensions.
  • The MimeType class allows:
    • Building instances from scratch using a fluent API,
    • Parsing and validating Internet Media Types,
    • Editing Internet Media Type parameters,
    • Serializing Internet Media Types as strings according to the standards (see RFC 2045 and RFC 2231) using several formatting options,
    • Retrieving a file type extension.
  • The MimeTypeInfo struct allows memory efficient parsing, validating, and reformatting of Internet Media Type strings and allows to retrieve an appropriate file type extension.

The library is designed to support performance and small heap allocation.

The data for the file type extension parser is collected from:

  1. Apache
  2. jshttp/mime-db
  3. own research.

(The collected data was considered in the specified order. Have a detailed explanation about how this data is ordered and compiled in the comments of MimeResourceCompiler, which is part of this repository.)

Version History

Code Examples

  1. Getting an Internet Media Type ("MIME type") string from a file type extension and vice versa
  2. Building, serializing, parsing, and editing of MimeType instances
  3. Formatting a MimeType instance into a standards-compliant string using several options
  4. Comparison of MimeType instances
  5. Efficient parsing of an Internet Media Type String