wirm/Game/Assets/Supabase/MimeMapping.2.0.0
2025-01-31 14:38:57 +08:00
..
lib game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00
.signature.p7s game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00
lib.meta game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00
MimeMapping.2.0.0.nupkg game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00
MimeMapping.2.0.0.nupkg.meta game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00
README.md game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00
README.md.meta game(deps/dda): the great supabase addition 2025-01-31 14:38:57 +08:00

MimeMapping

Nuget Nuget build codecov

Constants for (almost) all MIME types and method to determine MIME type from a file name. Contains just over 1000 mime types.

The Dictionary is generated from the jshttp/mime-db db.json. Works similar to .NET's System.Web.MimeMapping.GetMimeMapping.

It aggregates data from the following sources:

The library is just a literal C# Dictionary<string, string> with over 1000 entries, and a helper method that can be passed a file path.

Example Usage

string myFile = "myimage.jpg";
string mimeType = MimeMapping.MimeUtility.GetMimeMapping(myFile);
Console.WriteLine(mimeType); // output: image/jpeg

string randomFile = "data.asdf";
string mimeType = MimeMapping.MimeUtility.GetMimeMapping(randomFile);
Console.WriteLine(mimeType); // output: application/octet-stream

string rawExtension = "json";
string mimeType = MimeMapping.MimeUtility.GetMimeMapping(rawExtension);
Console.WriteLine(mimeType); // output: application/json


// List all types..
foreach(var kp in MimeMapping.MimeTypes.TypeMap)
{
  Console.WriteLine($"File extension: {kp.Key}, mime string: {kp.Value}");
}