Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 204 additions & 6 deletions src/main/java/be/ugent/knows/idlabFunctions/IDLabFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,212 @@ public static String getMIMEType(String filename) {
HashMap<String, String> map = new HashMap<>();

// Put elements in the hashMap
map.put("csv", "text/csv");
map.put("json", "application/json");
map.put("xml", "application/xml");
map.put("nt", "application/n-triples");
map.put("ttl", "text/turtle");
map.put("nq", "application/n-quads");
map.put("sql", "application/sql");


// The rest of this list of mappings derived from CPython
// Source: https://github.com/python/cpython/blob/8bc3aa9ac3bf4ccb5a95b56ffac04c3cb33b4433/Lib/mimetypes.py#L477
// Copyright (c) 2001-2026 Python Software Foundation; All Rights Reserved
// Licensed under the Python Software Foundation License Version 2.
map.put("js", "text/javascript");
map.put("mjs", "text/javascript");
map.put("epub", "application/epub+zip");
map.put("gz", "application/gzip");
map.put("json", "application/json");
map.put("webmanifest", "application/manifest+json");
map.put("doc", "application/msword");
map.put("dot", "application/msword");
map.put("wiz", "application/msword");
map.put("nq", "application/n-quads");
map.put("nt", "application/n-triples");
map.put("bin", "application/octet-stream");
map.put("a", "application/octet-stream");
map.put("dll", "application/octet-stream");
map.put("exe", "application/octet-stream");
map.put("o", "application/octet-stream");
map.put("obj", "application/octet-stream");
map.put("so", "application/octet-stream");
map.put("oda", "application/oda");
map.put("ogx", "application/ogg");
map.put("pdf", "application/pdf");
map.put("p7c", "application/pkcs7-mime");
map.put("ps", "application/postscript");
map.put("ai", "application/postscript");
map.put("eps", "application/postscript");
map.put("trig", "application/trig");
map.put("m3u", "application/vnd.apple.mpegurl");
map.put("m3u8", "application/vnd.apple.mpegurl");
map.put("xls", "application/vnd.ms-excel");
map.put("xlb", "application/vnd.ms-excel");
map.put("eot", "application/vnd.ms-fontobject");
map.put("ppt", "application/vnd.ms-powerpoint");
map.put("pot", "application/vnd.ms-powerpoint");
map.put("ppa", "application/vnd.ms-powerpoint");
map.put("pps", "application/vnd.ms-powerpoint");
map.put("pwz", "application/vnd.ms-powerpoint");
map.put("odg", "application/vnd.oasis.opendocument.graphics");
map.put("odp", "application/vnd.oasis.opendocument.presentation");
map.put("ods", "application/vnd.oasis.opendocument.spreadsheet");
map.put("odt", "application/vnd.oasis.opendocument.text");
map.put("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
map.put("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
map.put("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
map.put("rar", "application/vnd.rar");
map.put("wasm", "application/wasm");
map.put("7z", "application/x-7z-compressed");
map.put("bcpio", "application/x-bcpio");
map.put("cpio", "application/x-cpio");
map.put("csh", "application/x-csh");
map.put("deb", "application/x-debian-package");
map.put("dvi", "application/x-dvi");
map.put("gtar", "application/x-gtar");
map.put("hdf", "application/x-hdf");
map.put("h5", "application/x-hdf5");
map.put("latex", "application/x-latex");
map.put("mif", "application/x-mif");
map.put("cdf", "application/x-netcdf");
map.put("nc", "application/x-netcdf");
map.put("p12", "application/x-pkcs12");
map.put("php", "application/x-httpd-php");
map.put("pfx", "application/x-pkcs12");
map.put("ram", "application/x-pn-realaudio");
map.put("pyc", "application/x-python-code");
map.put("pyo", "application/x-python-code");
map.put("rpm", "application/x-rpm");
map.put("sh", "application/x-sh");
map.put("shar", "application/x-shar");
map.put("swf", "application/x-shockwave-flash");
map.put("sv4cpio", "application/x-sv4cpio");
map.put("sv4crc", "application/x-sv4crc");
map.put("tar", "application/x-tar");
map.put("tcl", "application/x-tcl");
map.put("tex", "application/x-tex");
map.put("texi", "application/x-texinfo");
map.put("texinfo", "application/x-texinfo");
map.put("roff", "application/x-troff");
map.put("t", "application/x-troff");
map.put("tr", "application/x-troff");
map.put("man", "application/x-troff-man");
map.put("me", "application/x-troff-me");
map.put("ms", "application/x-troff-ms");
map.put("ustar", "application/x-ustar");
map.put("src", "application/x-wais-source");
map.put("xsl", "application/xml");
map.put("rdf", "application/xml");
map.put("wsdl", "application/xml");
map.put("xpdl", "application/xml");
map.put("yaml", "application/yaml");
map.put("yml", "application/yaml");
map.put("zip", "application/zip");
map.put("3gp", "audio/3gpp");
map.put("3gpp", "audio/3gpp");
map.put("3g2", "audio/3gpp2");
map.put("3gpp2", "audio/3gpp2");
map.put("aac", "audio/aac");
map.put("adts", "audio/aac");
map.put("loas", "audio/aac");
map.put("ass", "audio/aac");
map.put("au", "audio/basic");
map.put("snd", "audio/basic");
map.put("flac", "audio/flac");
map.put("mka", "audio/matroska");
map.put("m4a", "audio/mp4");
map.put("mp3", "audio/mpeg");
map.put("mp2", "audio/mpeg");
map.put("ogg", "audio/ogg");
map.put("opus", "audio/opus");
map.put("aif", "audio/x-aiff");
map.put("aifc", "audio/x-aiff");
map.put("aiff", "audio/x-aiff");
map.put("ra", "audio/x-pn-realaudio");
map.put("wav", "audio/vnd.wave");
map.put("otf", "font/otf");
map.put("ttf", "font/ttf");
map.put("weba", "audio/webm");
map.put("woff", "font/woff");
map.put("woff2", "font/woff2");
map.put("avif", "image/avif");
map.put("bmp", "image/bmp");
map.put("emf", "image/emf");
map.put("fits", "image/fits");
map.put("g3", "image/g3fax");
map.put("gif", "image/gif");
map.put("ief", "image/ief");
map.put("jp2", "image/jp2");
map.put("jpg", "image/jpeg");
map.put("jpe", "image/jpeg");
map.put("jpeg", "image/jpeg");
map.put("jpm", "image/jpm");
map.put("jpx", "image/jpx");
map.put("heic", "image/heic");
map.put("heif", "image/heif");
map.put("png", "image/png");
map.put("svg", "image/svg+xml");
map.put("t38", "image/t38");
map.put("tiff", "image/tiff");
map.put("tif", "image/tiff");
map.put("tfx", "image/tiff-fx");
map.put("ico", "image/vnd.microsoft.icon");
map.put("webp", "image/webp");
map.put("wmf", "image/wmf");
map.put("ras", "image/x-cmu-raster");
map.put("pnm", "image/x-portable-anymap");
map.put("pbm", "image/x-portable-bitmap");
map.put("pgm", "image/x-portable-graymap");
map.put("ppm", "image/x-portable-pixmap");
map.put("rgb", "image/x-rgb");
map.put("xbm", "image/x-xbitmap");
map.put("xpm", "image/x-xpixmap");
map.put("xwd", "image/x-xwindowdump");
map.put("eml", "message/rfc822");
map.put("mht", "message/rfc822");
map.put("mhtml", "message/rfc822");
map.put("nws", "message/rfc822");
map.put("gltf", "model/gltf+json");
map.put("glb", "model/gltf-binary");
map.put("stl", "model/stl");
map.put("css", "text/css");
map.put("csv", "text/csv");
map.put("html", "text/html");
map.put("htm", "text/html");
map.put("md", "text/markdown");
map.put("markdown", "text/markdown");
map.put("n3", "text/n3");
map.put("txt", "text/plain");
map.put("bat", "text/plain");
map.put("c", "text/plain");
map.put("h", "text/plain");
map.put("ksh", "text/plain");
map.put("pl", "text/plain");
map.put("srt", "text/plain");
map.put("rtx", "text/richtext");
map.put("rtf", "text/rtf");
map.put("tsv", "text/tab-separated-values");
map.put("vtt", "text/vtt");
map.put("py", "text/x-python");
map.put("rst", "text/x-rst");
map.put("etx", "text/x-setext");
map.put("sgm", "text/x-sgml");
map.put("sgml", "text/x-sgml");
map.put("vcf", "text/x-vcard");
map.put("xml", "text/xml");
map.put("mkv", "video/matroska");
map.put("mk3d", "video/matroska-3d");
map.put("mp4", "video/mp4");
map.put("mpeg", "video/mpeg");
map.put("m1v", "video/mpeg");
map.put("mpa", "video/mpeg");
map.put("mpe", "video/mpeg");
map.put("mpg", "video/mpeg");
map.put("ogv", "video/ogg");
map.put("mov", "video/quicktime");
map.put("qt", "video/quicktime");
map.put("webm", "video/webm");
map.put("avi", "video/vnd.avi");
map.put("m4v", "video/x-m4v");
map.put("wmv", "video/x-ms-wmv");
map.put("movie", "video/x-sgi-movie");

int lastIndexOfPoint = filename.lastIndexOf('.');
String extension = lastIndexOfPoint < 0 ? "" : filename.substring(Math.min(lastIndexOfPoint + 1, filename.length()));

Expand Down