Line data Source code
1 : /** 2 : Copyright (c) 2024 Stappler LLC <admin@stappler.dev> 3 : 4 : Permission is hereby granted, free of charge, to any person obtaining a copy 5 : of this software and associated documentation files (the "Software"), to deal 6 : in the Software without restriction, including without limitation the rights 7 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 : copies of the Software, and to permit persons to whom the Software is 9 : furnished to do so, subject to the following conditions: 10 : 11 : The above copyright notice and this permission notice shall be included in 12 : all copies or substantial portions of the Software. 13 : 14 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 : THE SOFTWARE. 21 : **/ 22 : 23 : #include "SPFilesystem.h" 24 : #include "SPString.h" 25 : 26 : #if MODULE_STAPPLER_BITMAP 27 : #include "SPBitmap.h" 28 : #endif 29 : 30 : namespace STAPPLER_VERSIONIZED stappler::filesystem { 31 : 32 : const char * MIME_TYPES = 33 : R"(application/andrew-inset ez 34 : application/applixware aw 35 : application/atom+xml atom 36 : application/atomcat+xml atomcat 37 : application/atomsvc+xml atomsvc 38 : application/ccxml+xml ccxml 39 : application/cdmi-capability cdmia 40 : application/cdmi-container cdmic 41 : application/cdmi-domain cdmid 42 : application/cdmi-object cdmio 43 : application/cdmi-queue cdmiq 44 : application/cu-seeme cu 45 : application/davmount+xml davmount 46 : application/docbook+xml dbk 47 : application/dssc+der dssc 48 : application/dssc+xml xdssc 49 : application/ecmascript ecma 50 : application/emma+xml emma 51 : application/epub+zip epub 52 : application/exi exi 53 : application/font-tdpfr pfr 54 : application/gml+xml gml 55 : application/gpx+xml gpx 56 : application/gxf gxf 57 : application/hyperstudio stk 58 : application/inkml+xml ink inkml 59 : application/ipfix ipfix 60 : application/java-archive jar 61 : application/java-serialized-object ser 62 : application/java-vm class 63 : application/javascript js 64 : application/json json 65 : application/jsonml+json jsonml 66 : application/lost+xml lostxml 67 : application/mac-binhex40 hqx 68 : application/mac-compactpro cpt 69 : application/mads+xml mads 70 : application/marc mrc 71 : application/marcxml+xml mrcx 72 : application/mathematica ma nb mb 73 : application/mathml+xml mathml 74 : application/mbox mbox 75 : application/mediaservercontrol+xml mscml 76 : application/metalink+xml metalink 77 : application/metalink4+xml meta4 78 : application/mets+xml mets 79 : application/mods+xml mods 80 : application/mp21 m21 mp21 81 : application/mp4 mp4s 82 : application/msword doc dot 83 : application/mxf mxf 84 : application/octet-stream bin dms lrf mar so dist distz pkg bpk dump elc deploy 85 : application/oda oda 86 : application/oebps-package+xml opf 87 : application/ogg ogx 88 : application/omdoc+xml omdoc 89 : application/onenote onetoc onetoc2 onetmp onepkg 90 : application/oxps oxps 91 : application/patch-ops-error+xml xer 92 : application/pdf pdf 93 : application/pgp-encrypted pgp 94 : application/pgp-signature asc sig 95 : application/pics-rules prf 96 : application/pkcs10 p10 97 : application/pkcs7-mime p7m p7c 98 : application/pkcs7-signature p7s 99 : application/pkcs8 p8 100 : application/pkix-attr-cert ac 101 : application/pkix-cert cer 102 : application/pkix-crl crl 103 : application/pkix-pkipath pkipath 104 : application/pkixcmp pki 105 : application/pls+xml pls 106 : application/postscript ai eps ps 107 : application/prs.cww cww 108 : application/pskc+xml pskcxml 109 : application/rdf+xml rdf 110 : application/reginfo+xml rif 111 : application/relax-ng-compact-syntax rnc 112 : application/resource-lists+xml rl 113 : application/resource-lists-diff+xml rld 114 : application/rls-services+xml rs 115 : application/rpki-ghostbusters gbr 116 : application/rpki-manifest mft 117 : application/rpki-roa roa 118 : application/rsd+xml rsd 119 : application/rss+xml rss 120 : application/rtf rtf 121 : application/sbml+xml sbml 122 : application/scvp-cv-request scq 123 : application/scvp-cv-response scs 124 : application/scvp-vp-request spq 125 : application/scvp-vp-response spp 126 : application/sdp sdp 127 : application/set-payment-initiation setpay 128 : application/set-registration-initiation setreg 129 : application/shf+xml shf 130 : application/smil+xml smi smil 131 : application/sparql-query rq 132 : application/sparql-results+xml srx 133 : application/srgs gram 134 : application/srgs+xml grxml 135 : application/sru+xml sru 136 : application/ssdl+xml ssdl 137 : application/ssml+xml ssml 138 : application/tei+xml tei teicorpus 139 : application/thraud+xml tfi 140 : application/timestamped-data tsd 141 : application/vnd.3gpp.pic-bw-large plb 142 : application/vnd.3gpp.pic-bw-small psb 143 : application/vnd.3gpp.pic-bw-var pvb 144 : application/vnd.3gpp2.tcap tcap 145 : application/vnd.3m.post-it-notes pwn 146 : application/vnd.accpac.simply.aso aso 147 : application/vnd.accpac.simply.imp imp 148 : application/vnd.acucobol acu 149 : application/vnd.acucorp atc acutc 150 : application/vnd.adobe.air-application-installer-package+zip air 151 : application/vnd.adobe.formscentral.fcdt fcdt 152 : application/vnd.adobe.fxp fxp fxpl 153 : application/vnd.adobe.xdp+xml xdp 154 : application/vnd.adobe.xfdf xfdf 155 : application/vnd.ahead.space ahead 156 : application/vnd.airzip.filesecure.azf azf 157 : application/vnd.airzip.filesecure.azs azs 158 : application/vnd.amazon.ebook azw 159 : application/vnd.americandynamics.acc acc 160 : application/vnd.amiga.ami ami 161 : application/vnd.android.package-archive apk 162 : application/vnd.anser-web-certificate-issue-initiation cii 163 : application/vnd.anser-web-funds-transfer-initiation fti 164 : application/vnd.antix.game-component atx 165 : application/vnd.apple.installer+xml mpkg 166 : application/vnd.apple.mpegurl m3u8 167 : application/vnd.aristanetworks.swi swi 168 : application/vnd.astraea-software.iota iota 169 : application/vnd.audiograph aep 170 : application/vnd.blueice.multipass mpm 171 : application/vnd.bmi bmi 172 : application/vnd.businessobjects rep 173 : application/vnd.chemdraw+xml cdxml 174 : application/vnd.chipnuts.karaoke-mmd mmd 175 : application/vnd.cinderella cdy 176 : application/vnd.claymore cla 177 : application/vnd.cloanto.rp9 rp9 178 : application/vnd.clonk.c4group c4g c4d c4f c4p c4u 179 : application/vnd.cluetrust.cartomobile-config c11amc 180 : application/vnd.cluetrust.cartomobile-config-pkg c11amz 181 : application/vnd.commonspace csp 182 : application/vnd.contact.cmsg cdbcmsg 183 : application/vnd.cosmocaller cmc 184 : application/vnd.crick.clicker clkx 185 : application/vnd.crick.clicker.keyboard clkk 186 : application/vnd.crick.clicker.palette clkp 187 : application/vnd.crick.clicker.template clkt 188 : application/vnd.crick.clicker.wordbank clkw 189 : application/vnd.criticaltools.wbs+xml wbs 190 : application/vnd.ctc-posml pml 191 : application/vnd.cups-ppd ppd 192 : application/vnd.curl.car car 193 : application/vnd.curl.pcurl pcurl 194 : application/vnd.dart dart 195 : application/vnd.data-vision.rdz rdz 196 : application/vnd.dece.data uvf uvvf uvd uvvd 197 : application/vnd.dece.ttml+xml uvt uvvt 198 : application/vnd.dece.unspecified uvx uvvx 199 : application/vnd.dece.zip uvz uvvz 200 : application/vnd.denovo.fcselayout-link fe_launch 201 : application/vnd.dna dna 202 : application/vnd.dolby.mlp mlp 203 : application/vnd.dpgraph dpg 204 : application/vnd.dreamfactory dfac 205 : application/vnd.ds-keypoint kpxx 206 : application/vnd.dvb.ait ait 207 : application/vnd.dvb.service svc 208 : application/vnd.dynageo geo 209 : application/vnd.ecowin.chart mag 210 : application/vnd.enliven nml 211 : application/vnd.epson.esf esf 212 : application/vnd.epson.msf msf 213 : application/vnd.epson.quickanime qam 214 : application/vnd.epson.salt slt 215 : application/vnd.epson.ssf ssf 216 : application/vnd.eszigno3+xml es3 et3 217 : application/vnd.ezpix-album ez2 218 : application/vnd.ezpix-package ez3 219 : application/vnd.fdf fdf 220 : application/vnd.fdsn.mseed mseed 221 : application/vnd.fdsn.seed seed dataless 222 : application/vnd.flographit gph 223 : application/vnd.fluxtime.clip ftc 224 : application/vnd.framemaker fm frame maker book 225 : application/vnd.frogans.fnc fnc 226 : application/vnd.frogans.ltf ltf 227 : application/vnd.fsc.weblaunch fsc 228 : application/vnd.fujitsu.oasys oas 229 : application/vnd.fujitsu.oasys2 oa2 230 : application/vnd.fujitsu.oasys3 oa3 231 : application/vnd.fujitsu.oasysgp fg5 232 : application/vnd.fujitsu.oasysprs bh2 233 : application/vnd.fujixerox.ddd ddd 234 : application/vnd.fujixerox.docuworks xdw 235 : application/vnd.fujixerox.docuworks.binder xbd 236 : application/vnd.fuzzysheet fzs 237 : application/vnd.genomatix.tuxedo txd 238 : application/vnd.geogebra.file ggb 239 : application/vnd.geogebra.tool ggt 240 : application/vnd.geometry-explorer gex gre 241 : application/vnd.geonext gxt 242 : application/vnd.geoplan g2w 243 : application/vnd.geospace g3w 244 : application/vnd.gmx gmx 245 : application/vnd.google-earth.kml+xml kml 246 : application/vnd.google-earth.kmz kmz 247 : application/vnd.grafeq gqf gqs 248 : application/vnd.groove-account gac 249 : application/vnd.groove-help ghf 250 : application/vnd.groove-identity-message gim 251 : application/vnd.groove-injector grv 252 : application/vnd.groove-tool-message gtm 253 : application/vnd.groove-tool-template tpl 254 : application/vnd.groove-vcard vcg 255 : application/vnd.hal+xml hal 256 : application/vnd.handheld-entertainment+xml zmm 257 : application/vnd.hbci hbci 258 : application/vnd.hhe.lesson-player les 259 : application/vnd.hp-hpgl hpgl 260 : application/vnd.hp-hpid hpid 261 : application/vnd.hp-hps hps 262 : application/vnd.hp-jlyt jlt 263 : application/vnd.hp-pcl pcl 264 : application/vnd.hp-pclxl pclxl 265 : application/vnd.hydrostatix.sof-data sfd-hdstx 266 : application/vnd.ibm.minipay mpy 267 : application/vnd.ibm.modcap afp listafp list3820 268 : application/vnd.ibm.rights-management irm 269 : application/vnd.ibm.secure-container sc 270 : application/vnd.iccprofile icc icm 271 : application/vnd.igloader igl 272 : application/vnd.immervision-ivp ivp 273 : application/vnd.immervision-ivu ivu 274 : application/vnd.insors.igm igm 275 : application/vnd.intercon.formnet xpw xpx 276 : application/vnd.intergeo i2g 277 : application/vnd.intu.qbo qbo 278 : application/vnd.intu.qfx qfx 279 : application/vnd.ipunplugged.rcprofile rcprofile 280 : application/vnd.irepository.package+xml irp 281 : application/vnd.is-xpr xpr 282 : application/vnd.isac.fcs fcs 283 : application/vnd.jam jam 284 : application/vnd.jcp.javame.midlet-rms rms 285 : application/vnd.jisp jisp 286 : application/vnd.joost.joda-archive joda 287 : application/vnd.kahootz ktz ktr 288 : application/vnd.kde.karbon karbon 289 : application/vnd.kde.kchart chrt 290 : application/vnd.kde.kformula kfo 291 : application/vnd.kde.kivio flw 292 : application/vnd.kde.kontour kon 293 : application/vnd.kde.kpresenter kpr kpt 294 : application/vnd.kde.kspread ksp 295 : application/vnd.kde.kword kwd kwt 296 : application/vnd.kenameaapp htke 297 : application/vnd.kidspiration kia 298 : application/vnd.kinar kne knp 299 : application/vnd.koan skp skd skt skm 300 : application/vnd.kodak-descriptor sse 301 : application/vnd.las.las+xml lasxml 302 : application/vnd.llamagraphics.life-balance.desktop lbd 303 : application/vnd.llamagraphics.life-balance.exchange+xml lbe 304 : application/vnd.lotus-1-2-3 123 305 : application/vnd.lotus-approach apr 306 : application/vnd.lotus-freelance pre 307 : application/vnd.lotus-notes nsf 308 : application/vnd.lotus-organizer org 309 : application/vnd.lotus-screencam scm 310 : application/vnd.lotus-wordpro lwp 311 : application/vnd.macports.portpkg portpkg 312 : application/vnd.mcd mcd 313 : application/vnd.medcalcdata mc1 314 : application/vnd.mediastation.cdkey cdkey 315 : application/vnd.mfer mwf 316 : application/vnd.mfmp mfm 317 : application/vnd.micrografx.flo flo 318 : application/vnd.micrografx.igx igx 319 : application/vnd.mif mif 320 : application/vnd.mobius.daf daf 321 : application/vnd.mobius.dis dis 322 : application/vnd.mobius.mbk mbk 323 : application/vnd.mobius.mqy mqy 324 : application/vnd.mobius.msl msl 325 : application/vnd.mobius.plc plc 326 : application/vnd.mobius.txf txf 327 : application/vnd.mophun.application mpn 328 : application/vnd.mophun.certificate mpc 329 : application/vnd.mozilla.xul+xml xul 330 : application/vnd.ms-artgalry cil 331 : application/vnd.ms-cab-compressed cab 332 : application/vnd.ms-excel xls xlm xla xlc xlt xlw 333 : application/vnd.ms-excel.addin.macroenabled.12 xlam 334 : application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb 335 : application/vnd.ms-excel.sheet.macroenabled.12 xlsm 336 : application/vnd.ms-excel.template.macroenabled.12 xltm 337 : application/vnd.ms-fontobject eot 338 : application/vnd.ms-htmlhelp chm 339 : application/vnd.ms-ims ims 340 : application/vnd.ms-lrm lrm 341 : application/vnd.ms-officetheme thmx 342 : application/vnd.ms-pki.seccat cat 343 : application/vnd.ms-pki.stl stl 344 : application/vnd.ms-powerpoint ppt pps pot 345 : application/vnd.ms-powerpoint.addin.macroenabled.12 ppam 346 : application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm 347 : application/vnd.ms-powerpoint.slide.macroenabled.12 sldm 348 : application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm 349 : application/vnd.ms-powerpoint.template.macroenabled.12 potm 350 : application/vnd.ms-project mpp mpt 351 : application/vnd.ms-word.document.macroenabled.12 docm 352 : application/vnd.ms-word.template.macroenabled.12 dotm 353 : application/vnd.ms-works wps wks wcm wdb 354 : application/vnd.ms-wpl wpl 355 : application/vnd.ms-xpsdocument xps 356 : application/vnd.mseq mseq 357 : application/vnd.musician mus 358 : application/vnd.muvee.style msty 359 : application/vnd.mynfc taglet 360 : application/vnd.neurolanguage.nlu nlu 361 : application/vnd.nitf ntf nitf 362 : application/vnd.noblenet-directory nnd 363 : application/vnd.noblenet-sealer nns 364 : application/vnd.noblenet-web nnw 365 : application/vnd.nokia.n-gage.data ngdat 366 : application/vnd.nokia.n-gage.symbian.install n-gage 367 : application/vnd.nokia.radio-preset rpst 368 : application/vnd.nokia.radio-presets rpss 369 : application/vnd.novadigm.edm edm 370 : application/vnd.novadigm.edx edx 371 : application/vnd.novadigm.ext ext 372 : application/vnd.oasis.opendocument.chart odc 373 : application/vnd.oasis.opendocument.chart-template otc 374 : application/vnd.oasis.opendocument.database odb 375 : application/vnd.oasis.opendocument.formula odf 376 : application/vnd.oasis.opendocument.formula-template odft 377 : application/vnd.oasis.opendocument.graphics odg 378 : application/vnd.oasis.opendocument.graphics-template otg 379 : application/vnd.oasis.opendocument.image odi 380 : application/vnd.oasis.opendocument.image-template oti 381 : application/vnd.oasis.opendocument.presentation odp 382 : application/vnd.oasis.opendocument.presentation-template otp 383 : application/vnd.oasis.opendocument.spreadsheet ods 384 : application/vnd.oasis.opendocument.spreadsheet-template ots 385 : application/vnd.oasis.opendocument.text odt 386 : application/vnd.oasis.opendocument.text-master odm 387 : application/vnd.oasis.opendocument.text-template ott 388 : application/vnd.oasis.opendocument.text-web oth 389 : application/vnd.olpc-sugar xo 390 : application/vnd.oma.dd2+xml dd2 391 : application/vnd.openofficeorg.extension oxt 392 : application/vnd.openxmlformats-officedocument.presentationml.presentation pptx 393 : application/vnd.openxmlformats-officedocument.presentationml.slide sldx 394 : application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx 395 : application/vnd.openxmlformats-officedocument.presentationml.template potx 396 : application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx 397 : application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx 398 : application/vnd.openxmlformats-officedocument.wordprocessingml.document docx 399 : application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx 400 : application/vnd.osgeo.mapguide.package mgp 401 : application/vnd.osgi.dp dp 402 : application/vnd.osgi.subsystem esa 403 : application/vnd.palm pdb pqa oprc 404 : application/vnd.pawaafile paw 405 : application/vnd.pg.format str 406 : application/vnd.pg.osasli ei6 407 : application/vnd.picsel efif 408 : application/vnd.pmi.widget wg 409 : application/vnd.pocketlearn plf 410 : application/vnd.powerbuilder6 pbd 411 : application/vnd.previewsystems.box box 412 : application/vnd.proteus.magazine mgz 413 : application/vnd.publishare-delta-tree qps 414 : application/vnd.pvi.ptid1 ptid 415 : application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb 416 : application/vnd.realvnc.bed bed 417 : application/vnd.recordare.musicxml mxl 418 : application/vnd.recordare.musicxml+xml musicxml 419 : application/vnd.rig.cryptonote cryptonote 420 : application/vnd.rim.cod cod 421 : application/vnd.rn-realmedia rm 422 : application/vnd.rn-realmedia-vbr rmvb 423 : application/vnd.route66.link66+xml link66 424 : application/vnd.sailingtracker.track st 425 : application/vnd.seemail see 426 : application/vnd.sema sema 427 : application/vnd.semd semd 428 : application/vnd.semf semf 429 : application/vnd.shana.informed.formdata ifm 430 : application/vnd.shana.informed.formtemplate itp 431 : application/vnd.shana.informed.interchange iif 432 : application/vnd.shana.informed.package ipk 433 : application/vnd.simtech-mindmapper twd twds 434 : application/vnd.smaf mmf 435 : application/vnd.smart.teacher teacher 436 : application/vnd.solent.sdkm+xml sdkm sdkd 437 : application/vnd.spotfire.dxp dxp 438 : application/vnd.spotfire.sfs sfs 439 : application/vnd.stardivision.calc sdc 440 : application/vnd.stardivision.draw sda 441 : application/vnd.stardivision.impress sdd 442 : application/vnd.stardivision.math smf 443 : application/vnd.stardivision.writer sdw vor 444 : application/vnd.stardivision.writer-global sgl 445 : application/vnd.stepmania.package smzip 446 : application/vnd.stepmania.stepchart sm 447 : application/vnd.sun.xml.calc sxc 448 : application/vnd.sun.xml.calc.template stc 449 : application/vnd.sun.xml.draw sxd 450 : application/vnd.sun.xml.draw.template std 451 : application/vnd.sun.xml.impress sxi 452 : application/vnd.sun.xml.impress.template sti 453 : application/vnd.sun.xml.math sxm 454 : application/vnd.sun.xml.writer sxw 455 : application/vnd.sun.xml.writer.global sxg 456 : application/vnd.sun.xml.writer.template stw 457 : application/vnd.sus-calendar sus susp 458 : application/vnd.svd svd 459 : application/vnd.symbian.install sis sisx 460 : application/vnd.syncml+xml xsm 461 : application/vnd.syncml.dm+wbxml bdm 462 : application/vnd.syncml.dm+xml xdm 463 : application/vnd.tao.intent-module-archive tao 464 : application/vnd.tcpdump.pcap pcap cap dmp 465 : application/vnd.tmobile-livetv tmo 466 : application/vnd.trid.tpt tpt 467 : application/vnd.triscape.mxs mxs 468 : application/vnd.trueapp tra 469 : application/vnd.ufdl ufd ufdl 470 : application/vnd.uiq.theme utz 471 : application/vnd.umajin umj 472 : application/vnd.unity unityweb 473 : application/vnd.uoml+xml uoml 474 : application/vnd.vcx vcx 475 : application/vnd.visio vsd vst vss vsw 476 : application/vnd.visionary vis 477 : application/vnd.vsf vsf 478 : application/vnd.wap.wbxml wbxml 479 : application/vnd.wap.wmlc wmlc 480 : application/vnd.wap.wmlscriptc wmlsc 481 : application/vnd.webturbo wtb 482 : application/vnd.wolfram.player nbp 483 : application/vnd.wordperfect wpd 484 : application/vnd.wqd wqd 485 : application/vnd.wt.stf stf 486 : application/vnd.xara xar 487 : application/vnd.xfdl xfdl 488 : application/vnd.yamaha.hv-dic hvd 489 : application/vnd.yamaha.hv-script hvs 490 : application/vnd.yamaha.hv-voice hvp 491 : application/vnd.yamaha.openscoreformat osf 492 : application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg 493 : application/vnd.yamaha.smaf-audio saf 494 : application/vnd.yamaha.smaf-phrase spf 495 : application/vnd.yellowriver-custom-menu cmp 496 : application/vnd.zul zir zirz 497 : application/vnd.zzazz.deck+xml zaz 498 : application/voicexml+xml vxml 499 : application/widget wgt 500 : application/winhlp hlp 501 : application/wsdl+xml wsdl 502 : application/wspolicy+xml wspolicy 503 : application/x-7z-compressed 7z 504 : application/x-abiword abw 505 : application/x-ace-compressed ace 506 : application/x-apple-diskimage dmg 507 : application/x-authorware-bin aab x32 u32 vox 508 : application/x-authorware-map aam 509 : application/x-authorware-seg aas 510 : application/x-bcpio bcpio 511 : application/x-bittorrent torrent 512 : application/x-blorb blb blorb 513 : application/x-bzip bz 514 : application/x-bzip2 bz2 boz 515 : application/x-cbr cbr cba cbt cbz cb7 516 : application/x-cdlink vcd 517 : application/x-cfs-compressed cfs 518 : application/x-chat chat 519 : application/x-chess-pgn pgn 520 : application/x-conference nsc 521 : application/x-cpio cpio 522 : application/x-csh csh 523 : application/x-debian-package deb udeb 524 : application/x-dgc-compressed dgc 525 : application/x-director dir dcr dxr cst cct cxt w3d fgd swa 526 : application/x-doom wad 527 : application/x-dtbncx+xml ncx 528 : application/x-dtbook+xml dtb 529 : application/x-dtbresource+xml res 530 : application/x-dvi dvi 531 : application/x-envoy evy 532 : application/x-eva eva 533 : application/x-font-bdf bdf 534 : application/x-font-ghostscript gsf 535 : application/x-font-linux-psf psf 536 : application/x-font-otf otf 537 : application/x-font-pcf pcf 538 : application/x-font-snf snf 539 : application/x-font-ttf ttf ttc 540 : application/x-font-type1 pfa pfb pfm afm 541 : application/x-font-woff woff 542 : application/x-freearc arc 543 : application/x-futuresplash spl 544 : application/x-gca-compressed gca 545 : application/x-glulx ulx 546 : application/x-gnumeric gnumeric 547 : application/x-gramps-xml gramps 548 : application/x-gtar gtar 549 : application/x-hdf hdf 550 : application/x-install-instructions install 551 : application/x-iso9660-image iso 552 : application/x-java-jnlp-file jnlp 553 : application/x-latex latex 554 : application/x-lzh-compressed lzh lha 555 : application/x-mie mie 556 : application/x-mobipocket-ebook prc mobi 557 : application/x-ms-application application 558 : application/x-ms-shortcut lnk 559 : application/x-ms-wmd wmd 560 : application/x-ms-wmz wmz 561 : application/x-ms-xbap xbap 562 : application/x-msaccess mdb 563 : application/x-msbinder obd 564 : application/x-mscardfile crd 565 : application/x-msclip clp 566 : application/x-msdownload exe dll com bat msi 567 : application/x-msmediaview mvb m13 m14 568 : application/x-msmetafile wmf wmz emf emz 569 : application/x-msmoney mny 570 : application/x-mspublisher pub 571 : application/x-msschedule scd 572 : application/x-msterminal trm 573 : application/x-mswrite wri 574 : application/x-netcdf nc cdf 575 : application/x-nzb nzb 576 : application/x-pkcs12 p12 pfx 577 : application/x-pkcs7-certificates p7b spc 578 : application/x-pkcs7-certreqresp p7r 579 : application/x-rar-compressed rar 580 : application/x-research-info-systems ris 581 : application/x-sh sh 582 : application/x-shar shar 583 : application/x-shockwave-flash swf 584 : application/x-silverlight-app xap 585 : application/x-sql sql 586 : application/x-stuffit sit 587 : application/x-stuffitx sitx 588 : application/x-subrip srt 589 : application/x-sv4cpio sv4cpio 590 : application/x-sv4crc sv4crc 591 : application/x-t3vm-image t3 592 : application/x-tads gam 593 : application/x-tar tar 594 : application/x-tcl tcl 595 : application/x-tex tex 596 : application/x-tex-tfm tfm 597 : application/x-texinfo texinfo texi 598 : application/x-tgif obj 599 : application/x-ustar ustar 600 : application/x-wais-source src 601 : application/x-x509-ca-cert der crt 602 : application/x-xfig fig 603 : application/x-xliff+xml xlf 604 : application/x-xpinstall xpi 605 : application/x-xz xz 606 : application/x-zmachine z1 z2 z3 z4 z5 z6 z7 z8 607 : application/xaml+xml xaml 608 : application/xcap-diff+xml xdf 609 : application/xenc+xml xenc 610 : application/xhtml+xml xhtml xht 611 : application/xml xml xsl 612 : application/xml-dtd dtd 613 : application/xop+xml xop 614 : application/xproc+xml xpl 615 : application/xslt+xml xslt 616 : application/xspf+xml xspf 617 : application/xv+xml mxml xhvml xvml xvm 618 : application/yang yang 619 : application/yin+xml yin 620 : application/zip zip 621 : audio/adpcm adp 622 : audio/basic au snd 623 : audio/midi mid midi kar rmi 624 : audio/mp4 mp4a 625 : audio/mpeg mpga mp2 mp2a mp3 m2a m3a 626 : audio/ogg oga ogg spx 627 : audio/s3m s3m 628 : audio/silk sil 629 : audio/vnd.dece.audio uva uvva 630 : audio/vnd.digital-winds eol 631 : audio/vnd.dra dra 632 : audio/vnd.dts dts 633 : audio/vnd.dts.hd dtshd 634 : audio/vnd.lucent.voice lvp 635 : audio/vnd.ms-playready.media.pya pya 636 : audio/vnd.nuera.ecelp4800 ecelp4800 637 : audio/vnd.nuera.ecelp7470 ecelp7470 638 : audio/vnd.nuera.ecelp9600 ecelp9600 639 : audio/vnd.rip rip 640 : audio/webm weba 641 : audio/x-aac aac 642 : audio/x-aiff aif aiff aifc 643 : audio/x-caf caf 644 : audio/x-flac flac 645 : audio/x-matroska mka 646 : audio/x-mpegurl m3u 647 : audio/x-ms-wax wax 648 : audio/x-ms-wma wma 649 : audio/x-pn-realaudio ram ra 650 : audio/x-pn-realaudio-plugin rmp 651 : audio/x-wav wav 652 : audio/xm xm 653 : chemical/x-cdx cdx 654 : chemical/x-cif cif 655 : chemical/x-cmdf cmdf 656 : chemical/x-cml cml 657 : chemical/x-csml csml 658 : chemical/x-xyz xyz 659 : image/bmp bmp 660 : image/cgm cgm 661 : image/g3fax g3 662 : image/gif gif 663 : image/ief ief 664 : image/jpeg jpeg jpg jpe 665 : image/ktx ktx 666 : image/png png 667 : image/prs.btif btif 668 : image/sgi sgi 669 : image/svg+xml svg svgz 670 : image/tiff tiff tif 671 : image/vnd.adobe.photoshop psd 672 : image/vnd.dece.graphic uvi uvvi uvg uvvg 673 : image/vnd.dvb.subtitle sub 674 : image/vnd.djvu djvu djv 675 : image/vnd.dwg dwg 676 : image/vnd.dxf dxf 677 : image/vnd.fastbidsheet fbs 678 : image/vnd.fpx fpx 679 : image/vnd.fst fst 680 : image/vnd.fujixerox.edmics-mmr mmr 681 : image/vnd.fujixerox.edmics-rlc rlc 682 : image/vnd.ms-modi mdi 683 : image/vnd.ms-photo wdp 684 : image/vnd.net-fpx npx 685 : image/vnd.wap.wbmp wbmp 686 : image/vnd.xiff xif 687 : image/webp webp 688 : image/x-3ds 3ds 689 : image/x-cmu-raster ras 690 : image/x-cmx cmx 691 : image/x-freehand fh fhc fh4 fh5 fh7 692 : image/x-icon ico 693 : image/x-mrsid-image sid 694 : image/x-pcx pcx 695 : image/x-pict pic pct 696 : image/x-portable-anymap pnm 697 : image/x-portable-bitmap pbm 698 : image/x-portable-graymap pgm 699 : image/x-portable-pixmap ppm 700 : image/x-rgb rgb 701 : image/x-tga tga 702 : image/x-xbitmap xbm 703 : image/x-xpixmap xpm 704 : image/x-xwindowdump xwd 705 : message/rfc822 eml mime 706 : model/iges igs iges 707 : model/mesh msh mesh silo 708 : model/vnd.collada+xml dae 709 : model/vnd.dwf dwf 710 : model/vnd.gdl gdl 711 : model/vnd.gtw gtw 712 : model/vnd.mts mts 713 : model/vnd.vtu vtu 714 : model/vrml wrl vrml 715 : model/x3d+binary x3db x3dbz 716 : model/x3d+vrml x3dv x3dvz 717 : model/x3d+xml x3d x3dz 718 : text/cache-manifest appcache 719 : text/calendar ics ifb 720 : text/css css 721 : text/csv csv 722 : text/html html htm 723 : text/n3 n3 724 : text/plain txt text conf def list log in 725 : text/prs.lines.tag dsc 726 : text/richtext rtx 727 : text/sgml sgml sgm 728 : text/tab-separated-values tsv 729 : text/troff t tr roff man me ms 730 : text/turtle ttl 731 : text/uri-list uri uris urls 732 : text/vcard vcard 733 : text/vnd.curl curl 734 : text/vnd.curl.dcurl dcurl 735 : text/vnd.curl.scurl scurl 736 : text/vnd.curl.mcurl mcurl 737 : text/vnd.dvb.subtitle sub 738 : text/vnd.fly fly 739 : text/vnd.fmi.flexstor flx 740 : text/vnd.graphviz gv 741 : text/vnd.in3d.3dml 3dml 742 : text/vnd.in3d.spot spot 743 : text/vnd.sun.j2me.app-descriptor jad 744 : text/vnd.wap.wml wml 745 : text/vnd.wap.wmlscript wmls 746 : text/x-asm s asm 747 : text/x-c c cc cxx cpp h hh dic 748 : text/x-fortran f for f77 f90 749 : text/x-java-source java 750 : text/x-opml opml 751 : text/x-pascal p pas 752 : text/x-nfo nfo 753 : text/x-setext etx 754 : text/x-sfv sfv 755 : text/x-uuencode uu 756 : text/x-vcalendar vcs 757 : text/x-vcard vcf 758 : video/3gpp 3gp 759 : video/3gpp2 3g2 760 : video/h261 h261 761 : video/h263 h263 762 : video/h264 h264 763 : video/jpeg jpgv 764 : video/jpm jpm jpgm 765 : video/mj2 mj2 mjp2 766 : video/mp4 mp4 mp4v mpg4 767 : video/mpeg mpeg mpg mpe m1v m2v 768 : video/ogg ogv 769 : video/quicktime qt mov 770 : video/vnd.dece.hd uvh uvvh 771 : video/vnd.dece.mobile uvm uvvm 772 : video/vnd.dece.pd uvp uvvp 773 : video/vnd.dece.sd uvs uvvs 774 : video/vnd.dece.video uvv uvvv 775 : video/vnd.dvb.file dvb 776 : video/vnd.fvt fvt 777 : video/vnd.mpegurl mxu m4u 778 : video/vnd.ms-playready.media.pyv pyv 779 : video/vnd.uvvu.mp4 uvu uvvu 780 : video/vnd.vivo viv 781 : video/webm webm 782 : video/x-f4v f4v 783 : video/x-fli fli 784 : video/x-flv flv 785 : video/x-m4v m4v 786 : video/x-matroska mkv mk3d mks 787 : video/x-mng mng 788 : video/x-ms-asf asf asx 789 : video/x-ms-vob vob 790 : video/x-ms-wm wm 791 : video/x-ms-wmv wmv 792 : video/x-ms-wmx wmx 793 : video/x-ms-wvx wvx 794 : video/x-msvideo avi 795 : video/x-sgi-movie movie 796 : video/x-smv smv 797 : x-conference/x-cooltalk ice)"; 798 : 799 : struct MimeDetector { 800 : std::unordered_map<StringView, StringView> extToMime; 801 : std::unordered_map<StringView, StringView> mimeToExt; 802 : 803 25 : MimeDetector() { 804 25 : StringView r(MIME_TYPES); 805 19150 : while (!r.empty()) { 806 19125 : auto str = r.readUntil<StringView::Chars<'\n', '\r'>>(); 807 19125 : r.skipChars<StringView::Chars<'\n', '\r'>>(); 808 19125 : if (!str.empty()) { 809 19125 : auto type = str.readUntil<StringView::CharGroup<CharGroupId::WhiteSpace>>(); 810 19125 : str.skipChars<StringView::CharGroup<CharGroupId::WhiteSpace>>(); 811 19125 : if (!str.empty()) { 812 43700 : while (!str.empty()) { 813 24575 : auto value = str.readUntil<StringView::CharGroup<CharGroupId::WhiteSpace>>(); 814 24575 : if (!value.empty()) { 815 24575 : extToMime.emplace(value, type); 816 24575 : mimeToExt.emplace(type, value); 817 : } 818 24575 : str.skipChars<StringView::CharGroup<CharGroupId::WhiteSpace>>(); 819 : } 820 : } 821 : } 822 : } 823 25 : } 824 : }; 825 : 826 : static MimeDetector s_mimeDetector; 827 : 828 25 : StringView detectMimeType(StringView path) { 829 25 : auto ext = filepath::lastExtension(path); 830 25 : if (!ext.empty()) { 831 25 : auto tmp = ext.str<memory::StandartInterface>(); 832 25 : string::apply_tolower_c(tmp); 833 25 : auto it = s_mimeDetector.extToMime.find(tmp); 834 25 : if (it != s_mimeDetector.extToMime.end()) { 835 25 : return it->second; 836 : } 837 25 : } 838 : 839 : #if MODULE_STAPPLER_BITMAP 840 : // try image format 841 0 : auto fmt = bitmap::detectFormat(StringView(path)); 842 0 : if (fmt.first != bitmap::FileFormat::Custom) { 843 0 : return bitmap::getMimeType(fmt.first); 844 : } else { 845 0 : return bitmap::getMimeType(fmt.second); 846 : } 847 : #endif 848 : return StringView(); 849 : } 850 : 851 : }