[NuGet] : MimeTypeMapOfficial
This is a Nuget that I use in NetCore2Blockly to know the type of the file embedded:
Link: https://www.nuget.org/packages/MimeTypeMapOfficial/
Site: https://github.com/samuelneff/MimeTypeMap
What it does: Provides a huge two-way mapping of file extensions to mime types and mime types to file extensions,
If no mime type is found then the generic “application/octet-stream” is returned.
Usage:
static string contentFromExtension(string file)
{
var dot = file.IndexOf(“.”);
if (dot < 1)
return “text/html”;var ext = file.Substring(dot+1).ToLowerInvariant();
return MimeTypeMap.GetMimeType(ext);}
Leave a Reply