Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NET library for file/mime type detection

I need a file type identification NET library (best 100% managed) with a similar functionality to TrIDEngine. I would ultimately need to pass a Stream representing content and expect the return value as either a MIME type or some enum/string easily mapped to a MIME type.

I want to detect just a handful of media types like WMV, WAV, MP3 and common image formats like JPEG, PNG, GIF and BMP.

The problem with TrIDEngine is the fact that it appears to only come in a form of a command line utility and expects a physical file path, not the required Stream.

like image 979
wpfwannabe Avatar asked Feb 02 '11 08:02

wpfwannabe


People also ask

What is MIME type detection?

MIME detection This uses the GNU file utility to determine the type of the file, which should work right away under Linux. Note that the file utility provided by other Unixes may not support the -i option, and will thus not work.

What is MIME type in C#?

MIME stands for "Multipurpose Internet Mail Extensions." It is a standard way of classifying file types on the Internet. By specifying a MIME type, application can easily identify the type of file and can extract more information and attributes about a file.

How do I fix MIME type error?

To Solve MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled ErrorJust make Sure Your File name and the name You are Using in Link Tag Both Are Same. For Example my File name is style. css Then My Link tag is Something like this:<link rel=”stylesheet” href=”style.


1 Answers

If you just need to detect a few file types you could lookup the format on Wikipedia and check for the header or "magic" bytes yourself. You can usually identify a file type from the first few bytes, so you can read a few bytes from the stream and check them yourself. Not exactly what you're asking for, but it shouldn't be too hard for only a few types.

like image 101
toby Avatar answered Oct 03 '22 10:10

toby