TwentyDevs.MimeTypeDetective
1.2.62
See the version list below for details.
dotnet add package TwentyDevs.MimeTypeDetective --version 1.2.62
NuGet\Install-Package TwentyDevs.MimeTypeDetective -Version 1.2.62
<PackageReference Include="TwentyDevs.MimeTypeDetective" Version="1.2.62" />
paket add TwentyDevs.MimeTypeDetective --version 1.2.62
#r "nuget: TwentyDevs.MimeTypeDetective, 1.2.62"
// Install TwentyDevs.MimeTypeDetective as a Cake Addin #addin nuget:?package=TwentyDevs.MimeTypeDetective&version=1.2.62 // Install TwentyDevs.MimeTypeDetective as a Cake Tool #tool nuget:?package=TwentyDevs.MimeTypeDetective&version=1.2.62
MimetypeDetective
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
Donate Us
<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 | Versions 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. |
-
.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.