Method DetectMimeType
DetectMimeType(string)
Detects the MIME type of the file at the specified path, using only the formats supported by the LM-Kit toolkit.
public static string DetectMimeType(string path)
Parameters
path
stringThe file system path to the file whose content will be inspected.
Returns
- string
A string representing the detected MIME type for supported formats (e.g. image/png, text/html, application/pdf, etc.), or an empty string if the file’s format is not recognized by the toolkit.
Remarks
Supported formats include, but are not limited to:
– Raster images: PNG, BMP, GIF, PSD, PIC, JPEG, PNM, HDR, TGA, WEBP, TIFF
– Text/HTML: .txt, .html
– Office and PDF: .pdf, .docx, .xlsx, .pptx
The method reads the file bytes and defers to DetectMimeType(byte[]) for actual detection logic.
Exceptions
- FileNotFoundException
Thrown if no file exists at the given
path
.- IOException
Thrown if an I/O error occurs while reading the file.
DetectMimeType(byte[])
Detects the MIME type of the provided byte array, using only the formats supported by the LMKit toolkit.
public static string DetectMimeType(byte[] content)
Parameters
content
byte[]A byte array containing the file data to inspect.
Returns
- string
A string representing the detected MIME type for supported formats, or an empty string if the content’s format is not recognized by the toolkit.
Remarks
Supported formats include, but are not limited to:
– Raster images: PNG, BMP, GIF, PSD, PIC, JPEG, PNM, HDR, TGA, WEBP, TIFF
– Text/HTML: .txt, .html
– Office and PDF: .pdf, .docx, .xlsx, .pptx
Detection is performed via the toolkit’s native image-format API, HTML sniffing, and (optionally) document-type utilities.