MimeTypeMapUnofficial-majora2007
1.0.19
dotnet add package MimeTypeMapUnofficial-majora2007 --version 1.0.19
NuGet\Install-Package MimeTypeMapUnofficial-majora2007 -Version 1.0.19
<PackageReference Include="MimeTypeMapUnofficial-majora2007" Version="1.0.19" />
paket add MimeTypeMapUnofficial-majora2007 --version 1.0.19
#r "nuget: MimeTypeMapUnofficial-majora2007, 1.0.19"
// Install MimeTypeMapUnofficial-majora2007 as a Cake Addin
#addin nuget:?package=MimeTypeMapUnofficial-majora2007&version=1.0.19
// Install MimeTypeMapUnofficial-majora2007 as a Cake Tool
#tool nuget:?package=MimeTypeMapUnofficial-majora2007&version=1.0.19
MimeTypeMap
Summary
Provides a huge two-way mapping of file extensions to mime types and mime types to file extensions, e.g.:
...
{".jpe", "image/jpeg"},
{".jpeg", "image/jpeg"},
{".jpg", "image/jpeg"},
{".js", "application/javascript"},
{".json", "application/json"},
...
Most mime types that have multiple possible extensions are pre-defined to get the most common extension when looking
up extension by mime type. Since multiple extensions can map to the same mime type, it is not necessary that GetExtension(GetMimeType(ext))
returns the original extension - it will return the most common extension.
Originally posted on StackOverflow here: http://stackoverflow.com/questions/1029740/get-mime-type-from-filename-extension
NuGet
There are several packages on NuGet built from this repo. The official one is at this URL.
https://www.nuget.org/packages/MimeTypeMapOfficial
Note that the NuGet package sometimes lags behind the code in GitHub when there are contributions from others and I forget to update. If you find this to be the case and need some of the updates, create an issue here and I'll update NuGet.
This is a fork of the official for use in Kavita.
Usage
After installation MimeTypeMap, include the following using statement in your class:
using MimeTypes;
Getting the mime type to an extension
Console.WriteLine("txt -> " + MimeTypeMap.GetMimeType("txt")); // "text/plain"
Pass in a string extension and get a mime type back. Optionally include the period. If not it will be added before looking up the mime type.
If no mime type is found then the generic "application/octet-stream" is returned.
Getting the extension to a mime type
Console.WriteLine("audio/wav -> " + MimeTypeMap.GetExtension("audio/wav")); // ".wav"
Pass in a mime type and get an extension back. If the mime type is not registered, an error is thrown.
Collaboration & Contribution Principles
All code is licensed under MIT 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 is compatible. 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 is compatible. |
.NET Standard | 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 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. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net7.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.
v1.0.19
- Added digital media extensions: cbz, cbr, cbt, cb7, 7zip, epub, tar.gz