This project uses a copy of /etc/media.types file from the media-types linux package.
The static constructor tries to read the embedded ressource "mime.types.gz" of the executing assembly. You can also use ReadMimeTypesFrom(Stream,..) to replace all mime types.
ReadMimeTypesFrom(Stream stream, bool disposeStream = false)
Stream can be either GZip compressed or raw.
One mime type per line followed by file suffixes seperated by any combination of ' ' or ',' or ';' or '\t'
'#' Marks a comment
Examples:
image/jpg jpg jpeg
video/jpg # Will be skipped since no suffix specified
IEnumerable<string> GetMimeTypeExtensions(string mimetype)
Returns an IEnumerable of all suffices for the specified mime type.
1. IEnumerable<string> GetMimeTypes(string fileName)
2. IEnumerable<string> GetMimeTypes()
- Returns an IEnumerable containing all found mime types, or FallbackMimeType if non was found.
fileName must contain '.' for example "test.png" or ".png" or "/test/test.png" for "image/png".
Throws ArgumentNullException if fileName is null. - Returns a distinct enumeration of all mime types
bool TryGetMimeType(string? fileName, out IEnumerable<string> mimeTypes)
True if the suffix is found. mimeTypes is a list of all found mime types.
fileName must contain '.' for example "test.png" or ".png" or "/test/test.png" for "image/png".
MimeTypes.MimeTypes.GetMimeType("test.png"); // returns { "image/png" }