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