TwentyDevs.MimeTypeDetective 1.10.70

dotnet add package TwentyDevs.MimeTypeDetective --version 1.10.70                
NuGet\Install-Package TwentyDevs.MimeTypeDetective -Version 1.10.70                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TwentyDevs.MimeTypeDetective" Version="1.10.70" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TwentyDevs.MimeTypeDetective --version 1.10.70                
#r "nuget: TwentyDevs.MimeTypeDetective, 1.10.70"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TwentyDevs.MimeTypeDetective as a Cake Addin
#addin nuget:?package=TwentyDevs.MimeTypeDetective&version=1.10.70

// Install TwentyDevs.MimeTypeDetective as a Cake Tool
#tool nuget:?package=TwentyDevs.MimeTypeDetective&version=1.10.70                

MimetypeDetective

Build&Test NuGet Badge

A simple library to detect mimetype of a file, stream or buffer array via magic numbers in the header content. It contains over 480 samples that as hardcoded in the library.

Detect mimetype of an extension string or mimetype string like “rar”, “exe”,” image/gif” …. It is possible to add more mimetypes in the library to detect files related to them. In fact, this library finds the mimetype via magic numbers.

Installing Package

Install-Package TwentyDevs.MimeTypeDetective

Or via the .NET Core command line interface:

dotnet add package TwentyDevs.MimeTypeDetective	

to detect a mimetype of a file with the address :

MimeTypeDetection.GetMimeType(filePath, Path.GetExtension(filePath));

In the example, passed the extension to method because some files like fdf, pdf, zip, and office files(xlsx, Docx, … ) have the same magic numbers, then detection must be done by extension. Also, it is possible to Detect the mimetype of streams and buffers (byte array) with the method.

To get the mimetype of an extension :

MimeTypeDetection.GetMimeTypeByExtension("rar");

To get other information about the particular mimetype :

MimeTypeDetection.GetMimeTypeinfoByMimetypeString("image/gif");

Except for mimetypes that are defined in the library you can add other mimetype to the mimetypes collection.

MimeTypes.Add
            (
                fileContent,
                headerOffset,
                headerSize,
                extension,
                mimeType,
                description,
                mustBeDetectByExtention
            );

There is a sample in the source code to add a new mimetype and then use it to detect a file (SVG File).

Using To File Validation

<a href="https://www.buymeacoffee.com/20devs" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.10.70 6,160 4/30/2023
1.8.68 596 4/30/2023
1.2.62 591 4/30/2023
1.0.60 791 11/30/2022
1.0.59 900 9/17/2022
1.0.57 871 9/15/2022
1.0.49 862 8/29/2022
1.0.46 833 8/22/2022
1.0.40 860 8/21/2022
1.0.38 817 8/20/2022