Skip to content

Instantly share code, notes, and snippets.

@fsans
Created June 1, 2022 07:07
Show Gist options
  • Save fsans/9675edc091cb3f838bd6ae5bb1926c36 to your computer and use it in GitHub Desktop.
Save fsans/9675edc091cb3f838bd6ae5bb1926c36 to your computer and use it in GitHub Desktop.

GetContainerMimeType(container)

Let(
ext = getContainerFileExtension ( data );
Case ( 
	ext = "aac" ; "audio/aac" ; 
	ext = "abw" ; "application/x-abiword" ; 
	ext = "arc" ; "application/x-freearc" ; 
	ext = "avi" ; "video/x-msvideo" ; 
	ext = "azw" ; "application/vnd.amazon.ebook" ; 
	ext = "bin" ; "application/octet-stream" ; 
	ext = "bmp" ; "image/bmp" ; 
	ext = "bz" ; "application/x-bzip" ; 
	ext = "bz2" ; "application/x-bzip2" ; 
	ext = "csh" ; "application/x-csh" ; 
	ext = "css" ; "text/css" ; 
	ext = "csv" ; "text/csv" ; 
	ext = "doc" ; "application/msword" ; 
	ext = "docx" ; "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ; 
	ext = "eot" ; "application/vnd.ms-fontobject" ; 
	ext = "epub" ; "application/epub+zip" ; 
	ext = "gif" ; "image/gif" ; 
	ext = "htm" ; "text/html" ; 
	ext = "html" ; "text/html" ; 
	ext = "ico" ; "image/vnd.microsoft.icon" ; 
	ext = "ics" ; "text/calendar" ; 
	ext = "jar" ; "application/java-archive" ; 
	ext = "jpeg" ; "image/jpeg" ; 
	ext = "jpg" ; "image/jpeg" ; 
	ext = "js" ; "text/javascript" ; 
	ext = "json" ; "application/json" ; 
	ext = "jsonld" ; "application/ld+json" ; 
	ext = "mid" ; "audio/midi audio/x-midi" ; 
	ext = "midi" ; "audio/midi audio/x-midi" ; 
	ext = "mjs" ; "text/javascript" ; 
	ext = "mp3" ; "audio/mpeg" ; 
	ext = "mpeg" ; "video/mpeg" ; 
	ext = "mpkg" ; "application/vnd.apple.installer+xml" ; 
	ext = "odp" ; "application/vnd.oasis.opendocument.presentation" ; 
	ext = "ods" ; "application/vnd.oasis.opendocument.spreadsheet" ; 
	ext = "odt" ; "application/vnd.oasis.opendocument.text" ; 
	ext = "oga" ; "audio/ogg" ; 
	ext = "ogv" ; "video/ogg" ; 
	ext = "ogx" ; "application/ogg" ; 
	ext = "otf" ; "font/otf" ; 
	ext = "png" ; "image/png" ; 
	ext = "pdf" ; "application/pdf" ; 
	ext = "ppt" ; "application/vnd.ms-powerpoint" ; 
	ext = "pptx" ; "application/vnd.openxmlformats-officedocument.presentationml.presentation" ; 
	ext = "rar" ; "application/x-rar-compressed" ; 
	ext = "rtf" ; "application/rtf" ; 
	ext = "sh" ; "application/x-sh" ; 
	ext = "svg" ; "image/svg+xml" ; 
	ext = "swf" ; "application/x-shockwave-flash" ; 
	ext = "tar" ; "application/x-tar" ; 
	ext = "tif" ; "image/tiff" ; 
	ext = "tiff" ; "image/tiff" ; 
	ext = "ttf" ; "font/ttf" ; 
	ext = "txt" ; "text/plain" ; 
	ext = "vsd" ; "application/vnd.visio" ; 
	ext = "wav" ; "audio/wav" ; 
	ext = "weba" ; "audio/webm" ; 
	ext = "webm" ; "video/webm" ; 
	ext = "webp" ; "image/webp" ; 
	ext = "woff" ; "font/woff" ; 
	ext = "woff2" ; "font/woff2" ; 
	ext = "xhtml" ; "application/xhtml+xml" ; 
	ext = "xls" ; "application/vnd.ms-excel" ; 
	ext = "xlsx" ; "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ; 
	ext = "xml" ; "application/xml" ; 
	ext = "xul" ; "application/vnd.mozilla.xul+xml" ; 
	ext = "zip" ; "application/zip" ; 
	ext = "3gp" ; "video/3gpp" ; 
	ext = "3g2" ; "video/3gpp2" ; 
	ext = "7z" ; "application/x-7z-compressed" ; 
	"application/octet-stream" // be aware of the risk of not registered extensions !!!
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment