Skip to content

Repository files navigation

MimeMapping

NugetNuget

Dictionary generated from the Apache Server mime.types file and the H5BP nginx mime.types file.

The Apache entries are used over others when collisions are found since they are from the official IANA registery. The others tend to use what works best for browsers or de facto standards (maybe we should use those ones instead, idk).

The lib 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

stringmyFile="myimage.jpg";stringmimeType=MimeMapping.MimeUtility.GetMimeMapping(myFile);Console.WriteLine(mimeType);// output: image/jpegstringrandomFile="data.asdf";stringmimeType=MimeMapping.MimeUtility.GetMimeMapping(randomFile);Console.WriteLine(mimeType);// output: application/octet-streamstringrawExtension="json";stringmimeType=MimeMapping.MimeUtility.GetMimeMapping(rawExtension);Console.WriteLine(mimeType);// output: application/json// List all types..foreach(varkpinMimeMapping.MimeTypes.TypeMap){Console.WriteLine($"File extension: {kp.Key}, mime string: {kp.Value}");}

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages