PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.MimeTypes Class Reference

Provides a mechanism for guessing the MIME type of a file by its extension. Of course, this isn't perfect - magic bytes are probably more reliable - but also more effort. This code is largely copied from https://github.com/samuelneff/MimeTypeMap/blob/master/MimeTypeMap.cs The code in this file is licensed under the. More...

Static Public Member Functions

static string GuessForFileName (string fileNameOrExtension)
 Tries to get the type of the MIME from the provided string.
static bool TryGuessExtensionForMimeType (string mimeType, out string extension)
 Gets the extension from the provided MINE type.
static bool IsTextMimeType (this string mimeType)
 Returns true for all text mime types: text/* *‍/xml *+xml.

Properties

static string[] KnownFileExtensions [get]
 A list of all known file extensions for MIMEType.
static string[] KnownMimeTypes [get]
 A list of all known MIME types for MIMEType.

Detailed Description

Provides a mechanism for guessing the MIME type of a file by its extension. Of course, this isn't perfect - magic bytes are probably more reliable - but also more effort. This code is largely copied from https://github.com/samuelneff/MimeTypeMap/blob/master/MimeTypeMap.cs The code in this file is licensed under the.

Member Function Documentation

◆ GuessForFileName()

string PeanutButter.Utils.MimeTypes.GuessForFileName ( string fileNameOrExtension)
static

Tries to get the type of the MIME from the provided string.

Parameters
fileNameOrExtensionThe filename or extension.
Returns
The MIME type.
Exceptions
ArgumentNullException

◆ IsTextMimeType()

bool PeanutButter.Utils.MimeTypes.IsTextMimeType ( this string mimeType)
static

Returns true for all text mime types: text/* *‍/xml *+xml.

Parameters
mimeType
Returns

◆ TryGuessExtensionForMimeType()

bool PeanutButter.Utils.MimeTypes.TryGuessExtensionForMimeType ( string mimeType,
out string extension )
static

Gets the extension from the provided MINE type.

Parameters
mimeTypeType of the MIME.
extensionThe resolved extension, if found.
Exceptions
ArgumentNullException
Exceptions
ArgumentException

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/MimeTypes.cs