Mime 3.4.1
See the version list below for details.
dotnet add package Mime --version 3.4.1
NuGet\Install-Package Mime -Version 3.4.1
<PackageReference Include="Mime" Version="3.4.1" />
paket add Mime --version 3.4.1
#r "nuget: Mime, 3.4.1"
// Install Mime as a Cake Addin #addin nuget:?package=Mime&version=3.4.1 // Install Mime as a Cake Tool #tool nuget:?package=Mime&version=3.4.1
Mime
.NET wrapper for libmagic
Install
via NuGet:
PM> Install-Package Mime
Requirements
Supports only x64 OS(Linux, MacOS and Windows).
Basic usage
using HeyRed.Mime;
// (Optionally) You can set path to magic database file manually.
MimeGuesser.MagicFilePath = "/path/to/magic/file";
// Guess mime type of file(overloaded method takes byte array or stream as arg.)
MimeGuesser.GuessMimeType("path/to/file"); //=> image/jpeg
// Get extension of file(overloaded method takes byte array or stream as arg.)
MimeGuesser.GuessExtension("path/to/file"); //=> jpeg
// Get mime type and extension of file(overloaded method takes byte array or stream as arg.)
MimeGuesser.GuessFileType("path/to/file"); //=> FileType
Advanced
Want more than just the mime type? Use the Magic class:
string calc = @"C:\Windows\System32\calc.exe";
using var magic = new Magic(MagicOpenFlags.MAGIC_NONE);
magic.Read(calc); //=> PE32+ executable (GUI) x86-64, for MS Windows
// Check encoding:
string textFile = @"F:\Temp\file.txt";
using var magic = new Magic(MagicOpenFlags.MAGIC_MIME_ENCODING);
magic.Read(textFile); //=> Output: utf-8
Also, we can combine flags with "|" operator. See all flags for more info.
Remarks
- The Magic class is not thread safe, but if you use different instances on different threads it seems to work fine.
- The MimeGuesser is thread safe, since it generates a new instance of Magic class on each use.
Possible problems
Exception | Solution |
---|---|
DllNotFoundException | Make sure that your bin folder contains runtimes directory. If you publishing platform dependent app, then bin should be contains libmagic-1 (.dll, .so or .dylib) and magic.mgc files. |
BadImageFormatException | Make sure when you target the AnyCPU platform the Prefer 32-bit option is unchecked. Or try to target x64 instead. |
License
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 | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.5 is compatible. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. 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.7.2
- MimeTypesMap (>= 1.0.8)
-
.NETFramework 4.8
- MimeTypesMap (>= 1.0.8)
-
.NETStandard 1.5
- MimeTypesMap (>= 1.0.8)
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.0
- MimeTypesMap (>= 1.0.8)
NuGet packages (11)
Showing the top 5 NuGet packages that depend on Mime:
Package | Downloads |
---|---|
NsfwSpy
NsfwSpy is an image and video classifier used to identify explicit/pornographic content using machine learning. |
|
SparkPostCore
.Net Core port of SparkPost class libary for using REST API. https://github.com/darrencauthon/csharp-sparkpost |
|
BXJG.Utils
Package Description |
|
DanSaul.SharedCode
Package Description |
|
Downlink
The main Downlink package including the controllers and infrastructure code |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Mime:
Repository | Stars |
---|---|
NsfwSpy/NsfwSpy.NET
A .NET image and video classifier used to identify explicit/pornographic content written in C#.
|
Version | Downloads | Last updated |
---|---|---|
3.6.0 | 205,488 | 12/5/2023 |
3.5.2 | 218,029 | 2/27/2023 |
3.5.1 | 1,246 | 2/25/2023 |
3.4.1 | 109,562 | 12/12/2022 |
3.4.0 | 166,269 | 5/22/2022 |
3.3.0 | 138,402 | 12/2/2021 |
3.2.3 | 253,151 | 7/5/2021 |
3.2.2 | 227,354 | 9/11/2020 |
3.2.1 | 1,386 | 9/11/2020 |
3.1.0 | 195,444 | 1/9/2020 |
3.0.2 | 1,047,050 | 10/23/2018 |
3.0.1 | 65,108 | 5/13/2018 |
3.0.0 | 65,016 | 12/28/2017 |
2.3.5 | 78,877 | 8/19/2017 |
2.3.4 | 2,798 | 8/17/2017 |
2.3.2 | 120,304 | 6/1/2017 |
2.3.1 | 2,978 | 5/30/2017 |
2.3.0 | 3,038 | 5/29/2017 |
2.2.0 | 3,305 | 5/13/2017 |
2.1.1 | 5,413 | 4/10/2017 |
2.1.0 | 3,042 | 4/8/2017 |
2.0.0 | 5,173 | 12/19/2016 |
1.3.2 | 4,018 | 11/8/2016 |
1.3.1 | 3,952 | 11/5/2016 |
1.3.0 | 3,433 | 11/4/2016 |
1.2.1 | 3,030 | 10/29/2016 |
1.2.0 | 3,036 | 10/28/2016 |
1.1.0 | 3,086 | 10/6/2016 |
1.0.0 | 4,309 | 9/28/2016 |