| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Faker\Provider;
|
|
|
4 |
|
|
|
5 |
class File extends Base
|
|
|
6 |
{
|
|
|
7 |
/**
|
|
|
8 |
* MIME types from the apache.org file. Some types are truncated.
|
|
|
9 |
*
|
|
|
10 |
* @var array Map of MIME types => file extension(s)
|
|
|
11 |
*
|
|
|
12 |
* @see http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
|
|
13 |
*/
|
|
|
14 |
protected static $mimeTypes = [
|
|
|
15 |
'application/atom+xml' => 'atom',
|
|
|
16 |
'application/ecmascript' => 'ecma',
|
|
|
17 |
'application/emma+xml' => 'emma',
|
|
|
18 |
'application/epub+zip' => 'epub',
|
|
|
19 |
'application/java-archive' => 'jar',
|
|
|
20 |
'application/java-vm' => 'class',
|
|
|
21 |
'application/javascript' => 'js',
|
|
|
22 |
'application/json' => 'json',
|
|
|
23 |
'application/jsonml+json' => 'jsonml',
|
|
|
24 |
'application/lost+xml' => 'lostxml',
|
|
|
25 |
'application/mathml+xml' => 'mathml',
|
|
|
26 |
'application/mets+xml' => 'mets',
|
|
|
27 |
'application/mods+xml' => 'mods',
|
|
|
28 |
'application/mp4' => 'mp4s',
|
|
|
29 |
'application/msword' => ['doc', 'dot'],
|
|
|
30 |
'application/octet-stream' => [
|
|
|
31 |
'bin',
|
|
|
32 |
'dms',
|
|
|
33 |
'lrf',
|
|
|
34 |
'mar',
|
|
|
35 |
'so',
|
|
|
36 |
'dist',
|
|
|
37 |
'distz',
|
|
|
38 |
'pkg',
|
|
|
39 |
'bpk',
|
|
|
40 |
'dump',
|
|
|
41 |
'elc',
|
|
|
42 |
'deploy',
|
|
|
43 |
],
|
|
|
44 |
'application/ogg' => 'ogx',
|
|
|
45 |
'application/omdoc+xml' => 'omdoc',
|
|
|
46 |
'application/pdf' => 'pdf',
|
|
|
47 |
'application/pgp-encrypted' => 'pgp',
|
|
|
48 |
'application/pgp-signature' => ['asc', 'sig'],
|
|
|
49 |
'application/pkix-pkipath' => 'pkipath',
|
|
|
50 |
'application/pkixcmp' => 'pki',
|
|
|
51 |
'application/pls+xml' => 'pls',
|
|
|
52 |
'application/postscript' => ['ai', 'eps', 'ps'],
|
|
|
53 |
'application/pskc+xml' => 'pskcxml',
|
|
|
54 |
'application/rdf+xml' => 'rdf',
|
|
|
55 |
'application/reginfo+xml' => 'rif',
|
|
|
56 |
'application/rss+xml' => 'rss',
|
|
|
57 |
'application/rtf' => 'rtf',
|
|
|
58 |
'application/sbml+xml' => 'sbml',
|
|
|
59 |
'application/vnd.adobe.air-application-installer-package+zip' => 'air',
|
|
|
60 |
'application/vnd.adobe.xdp+xml' => 'xdp',
|
|
|
61 |
'application/vnd.adobe.xfdf' => 'xfdf',
|
|
|
62 |
'application/vnd.ahead.space' => 'ahead',
|
|
|
63 |
'application/vnd.dart' => 'dart',
|
|
|
64 |
'application/vnd.data-vision.rdz' => 'rdz',
|
|
|
65 |
'application/vnd.dece.data' => ['uvf', 'uvvf', 'uvd', 'uvvd'],
|
|
|
66 |
'application/vnd.dece.ttml+xml' => ['uvt', 'uvvt'],
|
|
|
67 |
'application/vnd.dece.unspecified' => ['uvx', 'uvvx'],
|
|
|
68 |
'application/vnd.dece.zip' => ['uvz', 'uvvz'],
|
|
|
69 |
'application/vnd.denovo.fcselayout-link' => 'fe_launch',
|
|
|
70 |
'application/vnd.dna' => 'dna',
|
|
|
71 |
'application/vnd.dolby.mlp' => 'mlp',
|
|
|
72 |
'application/vnd.dpgraph' => 'dpg',
|
|
|
73 |
'application/vnd.dreamfactory' => 'dfac',
|
|
|
74 |
'application/vnd.ds-keypoint' => 'kpxx',
|
|
|
75 |
'application/vnd.dvb.ait' => 'ait',
|
|
|
76 |
'application/vnd.dvb.service' => 'svc',
|
|
|
77 |
'application/vnd.dynageo' => 'geo',
|
|
|
78 |
'application/vnd.ecowin.chart' => 'mag',
|
|
|
79 |
'application/vnd.enliven' => 'nml',
|
|
|
80 |
'application/vnd.epson.esf' => 'esf',
|
|
|
81 |
'application/vnd.epson.msf' => 'msf',
|
|
|
82 |
'application/vnd.epson.quickanime' => 'qam',
|
|
|
83 |
'application/vnd.epson.salt' => 'slt',
|
|
|
84 |
'application/vnd.epson.ssf' => 'ssf',
|
|
|
85 |
'application/vnd.ezpix-album' => 'ez2',
|
|
|
86 |
'application/vnd.ezpix-package' => 'ez3',
|
|
|
87 |
'application/vnd.fdf' => 'fdf',
|
|
|
88 |
'application/vnd.fdsn.mseed' => 'mseed',
|
|
|
89 |
'application/vnd.fdsn.seed' => ['seed', 'dataless'],
|
|
|
90 |
'application/vnd.flographit' => 'gph',
|
|
|
91 |
'application/vnd.fluxtime.clip' => 'ftc',
|
|
|
92 |
'application/vnd.hal+xml' => 'hal',
|
|
|
93 |
'application/vnd.hydrostatix.sof-data' => 'sfd-hdstx',
|
|
|
94 |
'application/vnd.ibm.minipay' => 'mpy',
|
|
|
95 |
'application/vnd.ibm.secure-container' => 'sc',
|
|
|
96 |
'application/vnd.iccprofile' => ['icc', 'icm'],
|
|
|
97 |
'application/vnd.igloader' => 'igl',
|
|
|
98 |
'application/vnd.immervision-ivp' => 'ivp',
|
|
|
99 |
'application/vnd.kde.karbon' => 'karbon',
|
|
|
100 |
'application/vnd.kde.kchart' => 'chrt',
|
|
|
101 |
'application/vnd.kde.kformula' => 'kfo',
|
|
|
102 |
'application/vnd.kde.kivio' => 'flw',
|
|
|
103 |
'application/vnd.kde.kontour' => 'kon',
|
|
|
104 |
'application/vnd.kde.kpresenter' => ['kpr', 'kpt'],
|
|
|
105 |
'application/vnd.kde.kspread' => 'ksp',
|
|
|
106 |
'application/vnd.kde.kword' => ['kwd', 'kwt'],
|
|
|
107 |
'application/vnd.kenameaapp' => 'htke',
|
|
|
108 |
'application/vnd.kidspiration' => 'kia',
|
|
|
109 |
'application/vnd.kinar' => ['kne', 'knp'],
|
|
|
110 |
'application/vnd.koan' => ['skp', 'skd', 'skt', 'skm'],
|
|
|
111 |
'application/vnd.kodak-descriptor' => 'sse',
|
|
|
112 |
'application/vnd.las.las+xml' => 'lasxml',
|
|
|
113 |
'application/vnd.llamagraphics.life-balance.desktop' => 'lbd',
|
|
|
114 |
'application/vnd.llamagraphics.life-balance.exchange+xml' => 'lbe',
|
|
|
115 |
'application/vnd.lotus-1-2-3' => '123',
|
|
|
116 |
'application/vnd.lotus-approach' => 'apr',
|
|
|
117 |
'application/vnd.lotus-freelance' => 'pre',
|
|
|
118 |
'application/vnd.lotus-notes' => 'nsf',
|
|
|
119 |
'application/vnd.lotus-organizer' => 'org',
|
|
|
120 |
'application/vnd.lotus-screencam' => 'scm',
|
|
|
121 |
'application/vnd.mozilla.xul+xml' => 'xul',
|
|
|
122 |
'application/vnd.ms-artgalry' => 'cil',
|
|
|
123 |
'application/vnd.ms-cab-compressed' => 'cab',
|
|
|
124 |
'application/vnd.ms-excel' => [
|
|
|
125 |
'xls',
|
|
|
126 |
'xlm',
|
|
|
127 |
'xla',
|
|
|
128 |
'xlc',
|
|
|
129 |
'xlt',
|
|
|
130 |
'xlw',
|
|
|
131 |
],
|
|
|
132 |
'application/vnd.ms-excel.addin.macroenabled.12' => 'xlam',
|
|
|
133 |
'application/vnd.ms-excel.sheet.binary.macroenabled.12' => 'xlsb',
|
|
|
134 |
'application/vnd.ms-excel.sheet.macroenabled.12' => 'xlsm',
|
|
|
135 |
'application/vnd.ms-excel.template.macroenabled.12' => 'xltm',
|
|
|
136 |
'application/vnd.ms-fontobject' => 'eot',
|
|
|
137 |
'application/vnd.ms-htmlhelp' => 'chm',
|
|
|
138 |
'application/vnd.ms-ims' => 'ims',
|
|
|
139 |
'application/vnd.ms-lrm' => 'lrm',
|
|
|
140 |
'application/vnd.ms-officetheme' => 'thmx',
|
|
|
141 |
'application/vnd.ms-pki.seccat' => 'cat',
|
|
|
142 |
'application/vnd.ms-pki.stl' => 'stl',
|
|
|
143 |
'application/vnd.ms-powerpoint' => ['ppt', 'pps', 'pot'],
|
|
|
144 |
'application/vnd.ms-powerpoint.addin.macroenabled.12' => 'ppam',
|
|
|
145 |
'application/vnd.ms-powerpoint.presentation.macroenabled.12' => 'pptm',
|
|
|
146 |
'application/vnd.ms-powerpoint.slide.macroenabled.12' => 'sldm',
|
|
|
147 |
'application/vnd.ms-powerpoint.slideshow.macroenabled.12' => 'ppsm',
|
|
|
148 |
'application/vnd.ms-powerpoint.template.macroenabled.12' => 'potm',
|
|
|
149 |
'application/vnd.ms-project' => ['mpp', 'mpt'],
|
|
|
150 |
'application/vnd.ms-word.document.macroenabled.12' => 'docm',
|
|
|
151 |
'application/vnd.ms-word.template.macroenabled.12' => 'dotm',
|
|
|
152 |
'application/vnd.ms-works' => ['wps', 'wks', 'wcm', 'wdb'],
|
|
|
153 |
'application/vnd.ms-wpl' => 'wpl',
|
|
|
154 |
'application/vnd.ms-xpsdocument' => 'xps',
|
|
|
155 |
'application/vnd.mseq' => 'mseq',
|
|
|
156 |
'application/vnd.musician' => 'mus',
|
|
|
157 |
'application/vnd.oasis.opendocument.chart' => 'odc',
|
|
|
158 |
'application/vnd.oasis.opendocument.chart-template' => 'otc',
|
|
|
159 |
'application/vnd.oasis.opendocument.database' => 'odb',
|
|
|
160 |
'application/vnd.oasis.opendocument.formula' => 'odf',
|
|
|
161 |
'application/vnd.oasis.opendocument.formula-template' => 'odft',
|
|
|
162 |
'application/vnd.oasis.opendocument.graphics' => 'odg',
|
|
|
163 |
'application/vnd.oasis.opendocument.graphics-template' => 'otg',
|
|
|
164 |
'application/vnd.oasis.opendocument.image' => 'odi',
|
|
|
165 |
'application/vnd.oasis.opendocument.image-template' => 'oti',
|
|
|
166 |
'application/vnd.oasis.opendocument.presentation' => 'odp',
|
|
|
167 |
'application/vnd.oasis.opendocument.presentation-template' => 'otp',
|
|
|
168 |
'application/vnd.oasis.opendocument.spreadsheet' => 'ods',
|
|
|
169 |
'application/vnd.oasis.opendocument.spreadsheet-template' => 'ots',
|
|
|
170 |
'application/vnd.oasis.opendocument.text' => 'odt',
|
|
|
171 |
'application/vnd.oasis.opendocument.text-master' => 'odm',
|
|
|
172 |
'application/vnd.oasis.opendocument.text-template' => 'ott',
|
|
|
173 |
'application/vnd.oasis.opendocument.text-web' => 'oth',
|
|
|
174 |
'application/vnd.olpc-sugar' => 'xo',
|
|
|
175 |
'application/vnd.oma.dd2+xml' => 'dd2',
|
|
|
176 |
'application/vnd.openofficeorg.extension' => 'oxt',
|
|
|
177 |
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx',
|
|
|
178 |
'application/vnd.openxmlformats-officedocument.presentationml.slide' => 'sldx',
|
|
|
179 |
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ppsx',
|
|
|
180 |
'application/vnd.openxmlformats-officedocument.presentationml.template' => 'potx',
|
|
|
181 |
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
|
|
|
182 |
'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'xltx',
|
|
|
183 |
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
|
|
|
184 |
'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'dotx',
|
|
|
185 |
'application/vnd.pvi.ptid1' => 'ptid',
|
|
|
186 |
'application/vnd.quark.quarkxpress' => [
|
|
|
187 |
'qxd',
|
|
|
188 |
'qxt',
|
|
|
189 |
'qwd',
|
|
|
190 |
'qwt',
|
|
|
191 |
'qxl',
|
|
|
192 |
'qxb',
|
|
|
193 |
],
|
|
|
194 |
'application/vnd.realvnc.bed' => 'bed',
|
|
|
195 |
'application/vnd.recordare.musicxml' => 'mxl',
|
|
|
196 |
'application/vnd.recordare.musicxml+xml' => 'musicxml',
|
|
|
197 |
'application/vnd.rig.cryptonote' => 'cryptonote',
|
|
|
198 |
'application/vnd.rim.cod' => 'cod',
|
|
|
199 |
'application/vnd.rn-realmedia' => 'rm',
|
|
|
200 |
'application/vnd.rn-realmedia-vbr' => 'rmvb',
|
|
|
201 |
'application/vnd.route66.link66+xml' => 'link66',
|
|
|
202 |
'application/vnd.sailingtracker.track' => 'st',
|
|
|
203 |
'application/vnd.seemail' => 'see',
|
|
|
204 |
'application/vnd.sema' => 'sema',
|
|
|
205 |
'application/vnd.semd' => 'semd',
|
|
|
206 |
'application/vnd.semf' => 'semf',
|
|
|
207 |
'application/vnd.shana.informed.formdata' => 'ifm',
|
|
|
208 |
'application/vnd.shana.informed.formtemplate' => 'itp',
|
|
|
209 |
'application/vnd.shana.informed.interchange' => 'iif',
|
|
|
210 |
'application/vnd.shana.informed.package' => 'ipk',
|
|
|
211 |
'application/vnd.simtech-mindmapper' => ['twd', 'twds'],
|
|
|
212 |
'application/vnd.smaf' => 'mmf',
|
|
|
213 |
'application/vnd.stepmania.stepchart' => 'sm',
|
|
|
214 |
'application/vnd.sun.xml.calc' => 'sxc',
|
|
|
215 |
'application/vnd.sun.xml.calc.template' => 'stc',
|
|
|
216 |
'application/vnd.sun.xml.draw' => 'sxd',
|
|
|
217 |
'application/vnd.sun.xml.draw.template' => 'std',
|
|
|
218 |
'application/vnd.sun.xml.impress' => 'sxi',
|
|
|
219 |
'application/vnd.sun.xml.impress.template' => 'sti',
|
|
|
220 |
'application/vnd.sun.xml.math' => 'sxm',
|
|
|
221 |
'application/vnd.sun.xml.writer' => 'sxw',
|
|
|
222 |
'application/vnd.sun.xml.writer.global' => 'sxg',
|
|
|
223 |
'application/vnd.sun.xml.writer.template' => 'stw',
|
|
|
224 |
'application/vnd.sus-calendar' => ['sus', 'susp'],
|
|
|
225 |
'application/vnd.svd' => 'svd',
|
|
|
226 |
'application/vnd.symbian.install' => ['sis', 'sisx'],
|
|
|
227 |
'application/vnd.syncml+xml' => 'xsm',
|
|
|
228 |
'application/vnd.syncml.dm+wbxml' => 'bdm',
|
|
|
229 |
'application/vnd.syncml.dm+xml' => 'xdm',
|
|
|
230 |
'application/vnd.tao.intent-module-archive' => 'tao',
|
|
|
231 |
'application/vnd.tcpdump.pcap' => ['pcap', 'cap', 'dmp'],
|
|
|
232 |
'application/vnd.tmobile-livetv' => 'tmo',
|
|
|
233 |
'application/vnd.trid.tpt' => 'tpt',
|
|
|
234 |
'application/vnd.triscape.mxs' => 'mxs',
|
|
|
235 |
'application/vnd.trueapp' => 'tra',
|
|
|
236 |
'application/vnd.ufdl' => ['ufd', 'ufdl'],
|
|
|
237 |
'application/vnd.uiq.theme' => 'utz',
|
|
|
238 |
'application/vnd.umajin' => 'umj',
|
|
|
239 |
'application/vnd.unity' => 'unityweb',
|
|
|
240 |
'application/vnd.uoml+xml' => 'uoml',
|
|
|
241 |
'application/vnd.vcx' => 'vcx',
|
|
|
242 |
'application/vnd.visio' => ['vsd', 'vst', 'vss', 'vsw'],
|
|
|
243 |
'application/vnd.visionary' => 'vis',
|
|
|
244 |
'application/vnd.vsf' => 'vsf',
|
|
|
245 |
'application/vnd.wap.wbxml' => 'wbxml',
|
|
|
246 |
'application/vnd.wap.wmlc' => 'wmlc',
|
|
|
247 |
'application/vnd.wap.wmlscriptc' => 'wmlsc',
|
|
|
248 |
'application/vnd.webturbo' => 'wtb',
|
|
|
249 |
'application/vnd.wolfram.player' => 'nbp',
|
|
|
250 |
'application/vnd.wordperfect' => 'wpd',
|
|
|
251 |
'application/vnd.wqd' => 'wqd',
|
|
|
252 |
'application/vnd.wt.stf' => 'stf',
|
|
|
253 |
'application/vnd.xara' => 'xar',
|
|
|
254 |
'application/vnd.xfdl' => 'xfdl',
|
|
|
255 |
'application/voicexml+xml' => 'vxml',
|
|
|
256 |
'application/widget' => 'wgt',
|
|
|
257 |
'application/winhlp' => 'hlp',
|
|
|
258 |
'application/wsdl+xml' => 'wsdl',
|
|
|
259 |
'application/wspolicy+xml' => 'wspolicy',
|
|
|
260 |
'application/x-7z-compressed' => '7z',
|
|
|
261 |
'application/x-bittorrent' => 'torrent',
|
|
|
262 |
'application/x-blorb' => ['blb', 'blorb'],
|
|
|
263 |
'application/x-bzip' => 'bz',
|
|
|
264 |
'application/x-cdlink' => 'vcd',
|
|
|
265 |
'application/x-cfs-compressed' => 'cfs',
|
|
|
266 |
'application/x-chat' => 'chat',
|
|
|
267 |
'application/x-chess-pgn' => 'pgn',
|
|
|
268 |
'application/x-conference' => 'nsc',
|
|
|
269 |
'application/x-cpio' => 'cpio',
|
|
|
270 |
'application/x-csh' => 'csh',
|
|
|
271 |
'application/x-debian-package' => ['deb', 'udeb'],
|
|
|
272 |
'application/x-dgc-compressed' => 'dgc',
|
|
|
273 |
'application/x-director' => [
|
|
|
274 |
'dir',
|
|
|
275 |
'dcr',
|
|
|
276 |
'dxr',
|
|
|
277 |
'cst',
|
|
|
278 |
'cct',
|
|
|
279 |
'cxt',
|
|
|
280 |
'w3d',
|
|
|
281 |
'fgd',
|
|
|
282 |
'swa',
|
|
|
283 |
],
|
|
|
284 |
'application/x-font-ttf' => ['ttf', 'ttc'],
|
|
|
285 |
'application/x-font-type1' => ['pfa', 'pfb', 'pfm', 'afm'],
|
|
|
286 |
'application/x-font-woff' => 'woff',
|
|
|
287 |
'application/x-freearc' => 'arc',
|
|
|
288 |
'application/x-futuresplash' => 'spl',
|
|
|
289 |
'application/x-gca-compressed' => 'gca',
|
|
|
290 |
'application/x-glulx' => 'ulx',
|
|
|
291 |
'application/x-gnumeric' => 'gnumeric',
|
|
|
292 |
'application/x-gramps-xml' => 'gramps',
|
|
|
293 |
'application/x-gtar' => 'gtar',
|
|
|
294 |
'application/x-hdf' => 'hdf',
|
|
|
295 |
'application/x-install-instructions' => 'install',
|
|
|
296 |
'application/x-iso9660-image' => 'iso',
|
|
|
297 |
'application/x-java-jnlp-file' => 'jnlp',
|
|
|
298 |
'application/x-latex' => 'latex',
|
|
|
299 |
'application/x-lzh-compressed' => ['lzh', 'lha'],
|
|
|
300 |
'application/x-mie' => 'mie',
|
|
|
301 |
'application/x-mobipocket-ebook' => ['prc', 'mobi'],
|
|
|
302 |
'application/x-ms-application' => 'application',
|
|
|
303 |
'application/x-ms-shortcut' => 'lnk',
|
|
|
304 |
'application/x-ms-wmd' => 'wmd',
|
|
|
305 |
'application/x-ms-wmz' => 'wmz',
|
|
|
306 |
'application/x-ms-xbap' => 'xbap',
|
|
|
307 |
'application/x-msaccess' => 'mdb',
|
|
|
308 |
'application/x-msbinder' => 'obd',
|
|
|
309 |
'application/x-mscardfile' => 'crd',
|
|
|
310 |
'application/x-msclip' => 'clp',
|
|
|
311 |
'application/x-msdownload' => ['exe', 'dll', 'com', 'bat', 'msi'],
|
|
|
312 |
'application/x-msmediaview' => [
|
|
|
313 |
'mvb',
|
|
|
314 |
'm13',
|
|
|
315 |
'm14',
|
|
|
316 |
],
|
|
|
317 |
'application/x-msmetafile' => ['wmf', 'wmz', 'emf', 'emz'],
|
|
|
318 |
'application/x-rar-compressed' => 'rar',
|
|
|
319 |
'application/x-research-info-systems' => 'ris',
|
|
|
320 |
'application/x-sh' => 'sh',
|
|
|
321 |
'application/x-shar' => 'shar',
|
|
|
322 |
'application/x-shockwave-flash' => 'swf',
|
|
|
323 |
'application/x-silverlight-app' => 'xap',
|
|
|
324 |
'application/x-sql' => 'sql',
|
|
|
325 |
'application/x-stuffit' => 'sit',
|
|
|
326 |
'application/x-stuffitx' => 'sitx',
|
|
|
327 |
'application/x-subrip' => 'srt',
|
|
|
328 |
'application/x-sv4cpio' => 'sv4cpio',
|
|
|
329 |
'application/x-sv4crc' => 'sv4crc',
|
|
|
330 |
'application/x-t3vm-image' => 't3',
|
|
|
331 |
'application/x-tads' => 'gam',
|
|
|
332 |
'application/x-tar' => 'tar',
|
|
|
333 |
'application/x-tcl' => 'tcl',
|
|
|
334 |
'application/x-tex' => 'tex',
|
|
|
335 |
'application/x-tex-tfm' => 'tfm',
|
|
|
336 |
'application/x-texinfo' => ['texinfo', 'texi'],
|
|
|
337 |
'application/x-tgif' => 'obj',
|
|
|
338 |
'application/x-ustar' => 'ustar',
|
|
|
339 |
'application/x-wais-source' => 'src',
|
|
|
340 |
'application/x-x509-ca-cert' => ['der', 'crt'],
|
|
|
341 |
'application/x-xfig' => 'fig',
|
|
|
342 |
'application/x-xliff+xml' => 'xlf',
|
|
|
343 |
'application/x-xpinstall' => 'xpi',
|
|
|
344 |
'application/x-xz' => 'xz',
|
|
|
345 |
'application/x-zmachine' => 'z1',
|
|
|
346 |
'application/xaml+xml' => 'xaml',
|
|
|
347 |
'application/xcap-diff+xml' => 'xdf',
|
|
|
348 |
'application/xenc+xml' => 'xenc',
|
|
|
349 |
'application/xhtml+xml' => ['xhtml', 'xht'],
|
|
|
350 |
'application/xml' => ['xml', 'xsl'],
|
|
|
351 |
'application/xml-dtd' => 'dtd',
|
|
|
352 |
'application/xop+xml' => 'xop',
|
|
|
353 |
'application/xproc+xml' => 'xpl',
|
|
|
354 |
'application/xslt+xml' => 'xslt',
|
|
|
355 |
'application/xspf+xml' => 'xspf',
|
|
|
356 |
'application/xv+xml' => ['mxml', 'xhvml', 'xvml', 'xvm'],
|
|
|
357 |
'application/yang' => 'yang',
|
|
|
358 |
'application/yin+xml' => 'yin',
|
|
|
359 |
'application/zip' => 'zip',
|
|
|
360 |
'audio/adpcm' => 'adp',
|
|
|
361 |
'audio/basic' => ['au', 'snd'],
|
|
|
362 |
'audio/midi' => ['mid', 'midi', 'kar', 'rmi'],
|
|
|
363 |
'audio/mp4' => 'mp4a',
|
|
|
364 |
'audio/mpeg' => [
|
|
|
365 |
'mpga',
|
|
|
366 |
'mp2',
|
|
|
367 |
'mp2a',
|
|
|
368 |
'mp3',
|
|
|
369 |
'm2a',
|
|
|
370 |
'm3a',
|
|
|
371 |
],
|
|
|
372 |
'audio/ogg' => ['oga', 'ogg', 'spx'],
|
|
|
373 |
'audio/vnd.dece.audio' => ['uva', 'uvva'],
|
|
|
374 |
'audio/vnd.rip' => 'rip',
|
|
|
375 |
'audio/webm' => 'weba',
|
|
|
376 |
'audio/x-aac' => 'aac',
|
|
|
377 |
'audio/x-aiff' => ['aif', 'aiff', 'aifc'],
|
|
|
378 |
'audio/x-caf' => 'caf',
|
|
|
379 |
'audio/x-flac' => 'flac',
|
|
|
380 |
'audio/x-matroska' => 'mka',
|
|
|
381 |
'audio/x-mpegurl' => 'm3u',
|
|
|
382 |
'audio/x-ms-wax' => 'wax',
|
|
|
383 |
'audio/x-ms-wma' => 'wma',
|
|
|
384 |
'audio/x-pn-realaudio' => ['ram', 'ra'],
|
|
|
385 |
'audio/x-pn-realaudio-plugin' => 'rmp',
|
|
|
386 |
'audio/x-wav' => 'wav',
|
|
|
387 |
'audio/xm' => 'xm',
|
|
|
388 |
'image/bmp' => 'bmp',
|
|
|
389 |
'image/cgm' => 'cgm',
|
|
|
390 |
'image/g3fax' => 'g3',
|
|
|
391 |
'image/gif' => 'gif',
|
|
|
392 |
'image/ief' => 'ief',
|
|
|
393 |
'image/jpeg' => ['jpeg', 'jpg', 'jpe'],
|
|
|
394 |
'image/ktx' => 'ktx',
|
|
|
395 |
'image/png' => 'png',
|
|
|
396 |
'image/prs.btif' => 'btif',
|
|
|
397 |
'image/sgi' => 'sgi',
|
|
|
398 |
'image/svg+xml' => ['svg', 'svgz'],
|
|
|
399 |
'image/tiff' => ['tiff', 'tif'],
|
|
|
400 |
'image/vnd.adobe.photoshop' => 'psd',
|
|
|
401 |
'image/vnd.dece.graphic' => ['uvi', 'uvvi', 'uvg', 'uvvg'],
|
|
|
402 |
'image/vnd.dvb.subtitle' => 'sub',
|
|
|
403 |
'image/vnd.djvu' => ['djvu', 'djv'],
|
|
|
404 |
'image/vnd.dwg' => 'dwg',
|
|
|
405 |
'image/vnd.dxf' => 'dxf',
|
|
|
406 |
'image/vnd.fastbidsheet' => 'fbs',
|
|
|
407 |
'image/vnd.fpx' => 'fpx',
|
|
|
408 |
'image/vnd.fst' => 'fst',
|
|
|
409 |
'image/vnd.fujixerox.edmics-mmr' => 'mmr',
|
|
|
410 |
'image/vnd.fujixerox.edmics-rlc' => 'rlc',
|
|
|
411 |
'image/vnd.ms-modi' => 'mdi',
|
|
|
412 |
'image/vnd.ms-photo' => 'wdp',
|
|
|
413 |
'image/vnd.net-fpx' => 'npx',
|
|
|
414 |
'image/vnd.wap.wbmp' => 'wbmp',
|
|
|
415 |
'image/vnd.xiff' => 'xif',
|
|
|
416 |
'image/webp' => 'webp',
|
|
|
417 |
'image/x-3ds' => '3ds',
|
|
|
418 |
'image/x-cmu-raster' => 'ras',
|
|
|
419 |
'image/x-cmx' => 'cmx',
|
|
|
420 |
'image/x-freehand' => ['fh', 'fhc', 'fh4', 'fh5', 'fh7'],
|
|
|
421 |
'image/x-icon' => 'ico',
|
|
|
422 |
'image/x-mrsid-image' => 'sid',
|
|
|
423 |
'image/x-pcx' => 'pcx',
|
|
|
424 |
'image/x-pict' => ['pic', 'pct'],
|
|
|
425 |
'image/x-portable-anymap' => 'pnm',
|
|
|
426 |
'image/x-portable-bitmap' => 'pbm',
|
|
|
427 |
'image/x-portable-graymap' => 'pgm',
|
|
|
428 |
'image/x-portable-pixmap' => 'ppm',
|
|
|
429 |
'image/x-rgb' => 'rgb',
|
|
|
430 |
'image/x-tga' => 'tga',
|
|
|
431 |
'image/x-xbitmap' => 'xbm',
|
|
|
432 |
'image/x-xpixmap' => 'xpm',
|
|
|
433 |
'image/x-xwindowdump' => 'xwd',
|
|
|
434 |
'message/rfc822' => ['eml', 'mime'],
|
|
|
435 |
'model/iges' => ['igs', 'iges'],
|
|
|
436 |
'model/mesh' => ['msh', 'mesh', 'silo'],
|
|
|
437 |
'model/vnd.collada+xml' => 'dae',
|
|
|
438 |
'model/vnd.dwf' => 'dwf',
|
|
|
439 |
'model/vnd.gdl' => 'gdl',
|
|
|
440 |
'model/vnd.gtw' => 'gtw',
|
|
|
441 |
'model/vnd.mts' => 'mts',
|
|
|
442 |
'model/vnd.vtu' => 'vtu',
|
|
|
443 |
'model/vrml' => ['wrl', 'vrml'],
|
|
|
444 |
'model/x3d+binary' => 'x3db',
|
|
|
445 |
'model/x3d+vrml' => 'x3dv',
|
|
|
446 |
'model/x3d+xml' => 'x3d',
|
|
|
447 |
'text/cache-manifest' => 'appcache',
|
|
|
448 |
'text/calendar' => ['ics', 'ifb'],
|
|
|
449 |
'text/css' => 'css',
|
|
|
450 |
'text/csv' => 'csv',
|
|
|
451 |
'text/html' => ['html', 'htm'],
|
|
|
452 |
'text/n3' => 'n3',
|
|
|
453 |
'text/plain' => [
|
|
|
454 |
'txt',
|
|
|
455 |
'text',
|
|
|
456 |
'conf',
|
|
|
457 |
'def',
|
|
|
458 |
'list',
|
|
|
459 |
'log',
|
|
|
460 |
'in',
|
|
|
461 |
],
|
|
|
462 |
'text/prs.lines.tag' => 'dsc',
|
|
|
463 |
'text/richtext' => 'rtx',
|
|
|
464 |
'text/sgml' => ['sgml', 'sgm'],
|
|
|
465 |
'text/tab-separated-values' => 'tsv',
|
|
|
466 |
'text/troff' => [
|
|
|
467 |
't',
|
|
|
468 |
'tr',
|
|
|
469 |
'roff',
|
|
|
470 |
'man',
|
|
|
471 |
'me',
|
|
|
472 |
'ms',
|
|
|
473 |
],
|
|
|
474 |
'text/turtle' => 'ttl',
|
|
|
475 |
'text/uri-list' => ['uri', 'uris', 'urls'],
|
|
|
476 |
'text/vcard' => 'vcard',
|
|
|
477 |
'text/vnd.curl' => 'curl',
|
|
|
478 |
'text/vnd.curl.dcurl' => 'dcurl',
|
|
|
479 |
'text/vnd.curl.scurl' => 'scurl',
|
|
|
480 |
'text/vnd.curl.mcurl' => 'mcurl',
|
|
|
481 |
'text/vnd.dvb.subtitle' => 'sub',
|
|
|
482 |
'text/vnd.fly' => 'fly',
|
|
|
483 |
'text/vnd.fmi.flexstor' => 'flx',
|
|
|
484 |
'text/vnd.graphviz' => 'gv',
|
|
|
485 |
'text/vnd.in3d.3dml' => '3dml',
|
|
|
486 |
'text/vnd.in3d.spot' => 'spot',
|
|
|
487 |
'text/vnd.sun.j2me.app-descriptor' => 'jad',
|
|
|
488 |
'text/vnd.wap.wml' => 'wml',
|
|
|
489 |
'text/vnd.wap.wmlscript' => 'wmls',
|
|
|
490 |
'text/x-asm' => ['s', 'asm'],
|
|
|
491 |
'text/x-fortran' => ['f', 'for', 'f77', 'f90'],
|
|
|
492 |
'text/x-java-source' => 'java',
|
|
|
493 |
'text/x-opml' => 'opml',
|
|
|
494 |
'text/x-pascal' => ['p', 'pas'],
|
|
|
495 |
'text/x-nfo' => 'nfo',
|
|
|
496 |
'text/x-setext' => 'etx',
|
|
|
497 |
'text/x-sfv' => 'sfv',
|
|
|
498 |
'text/x-uuencode' => 'uu',
|
|
|
499 |
'text/x-vcalendar' => 'vcs',
|
|
|
500 |
'text/x-vcard' => 'vcf',
|
|
|
501 |
'video/3gpp' => '3gp',
|
|
|
502 |
'video/3gpp2' => '3g2',
|
|
|
503 |
'video/h261' => 'h261',
|
|
|
504 |
'video/h263' => 'h263',
|
|
|
505 |
'video/h264' => 'h264',
|
|
|
506 |
'video/jpeg' => 'jpgv',
|
|
|
507 |
'video/jpm' => ['jpm', 'jpgm'],
|
|
|
508 |
'video/mj2' => 'mj2',
|
|
|
509 |
'video/mp4' => 'mp4',
|
|
|
510 |
'video/mpeg' => ['mpeg', 'mpg', 'mpe', 'm1v', 'm2v'],
|
|
|
511 |
'video/ogg' => 'ogv',
|
|
|
512 |
'video/quicktime' => ['qt', 'mov'],
|
|
|
513 |
'video/vnd.dece.hd' => ['uvh', 'uvvh'],
|
|
|
514 |
'video/vnd.dece.mobile' => ['uvm', 'uvvm'],
|
|
|
515 |
'video/vnd.dece.pd' => ['uvp', 'uvvp'],
|
|
|
516 |
'video/vnd.dece.sd' => ['uvs', 'uvvs'],
|
|
|
517 |
'video/vnd.dece.video' => ['uvv', 'uvvv'],
|
|
|
518 |
'video/vnd.dvb.file' => 'dvb',
|
|
|
519 |
'video/vnd.fvt' => 'fvt',
|
|
|
520 |
'video/vnd.mpegurl' => ['mxu', 'm4u'],
|
|
|
521 |
'video/vnd.ms-playready.media.pyv' => 'pyv',
|
|
|
522 |
'video/vnd.uvvu.mp4' => ['uvu', 'uvvu'],
|
|
|
523 |
'video/vnd.vivo' => 'viv',
|
|
|
524 |
'video/webm' => 'webm',
|
|
|
525 |
'video/x-f4v' => 'f4v',
|
|
|
526 |
'video/x-fli' => 'fli',
|
|
|
527 |
'video/x-flv' => 'flv',
|
|
|
528 |
'video/x-m4v' => 'm4v',
|
|
|
529 |
'video/x-matroska' => ['mkv', 'mk3d', 'mks'],
|
|
|
530 |
'video/x-mng' => 'mng',
|
|
|
531 |
'video/x-ms-asf' => ['asf', 'asx'],
|
|
|
532 |
'video/x-ms-vob' => 'vob',
|
|
|
533 |
'video/x-ms-wm' => 'wm',
|
|
|
534 |
'video/x-ms-wmv' => 'wmv',
|
|
|
535 |
'video/x-ms-wmx' => 'wmx',
|
|
|
536 |
'video/x-ms-wvx' => 'wvx',
|
|
|
537 |
'video/x-msvideo' => 'avi',
|
|
|
538 |
'video/x-sgi-movie' => 'movie',
|
|
|
539 |
];
|
|
|
540 |
|
|
|
541 |
/**
|
|
|
542 |
* Get a random MIME type
|
|
|
543 |
*
|
|
|
544 |
* @return string
|
|
|
545 |
*
|
|
|
546 |
* @example 'video/avi'
|
|
|
547 |
*/
|
|
|
548 |
public static function mimeType()
|
|
|
549 |
{
|
|
|
550 |
return static::randomElement(array_keys(static::$mimeTypes));
|
|
|
551 |
}
|
|
|
552 |
|
|
|
553 |
/**
|
|
|
554 |
* Get a random file extension (without a dot)
|
|
|
555 |
*
|
|
|
556 |
* @example avi
|
|
|
557 |
*
|
|
|
558 |
* @return string
|
|
|
559 |
*/
|
|
|
560 |
public static function fileExtension()
|
|
|
561 |
{
|
|
|
562 |
$random_extension = static::randomElement(array_values(static::$mimeTypes));
|
|
|
563 |
|
|
|
564 |
return is_array($random_extension) ? static::randomElement($random_extension) : $random_extension;
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
/**
|
|
|
568 |
* Copy a random file from the source directory to the target directory and returns the filename/fullpath
|
|
|
569 |
*
|
|
|
570 |
* @param string $sourceDirectory The directory to look for random file taking
|
|
|
571 |
* @param string $targetDirectory
|
|
|
572 |
* @param bool $fullPath Whether to have the full path or just the filename
|
|
|
573 |
*
|
|
|
574 |
* @return string
|
|
|
575 |
*/
|
|
|
576 |
public static function file($sourceDirectory = '/tmp', $targetDirectory = '/tmp', $fullPath = true)
|
|
|
577 |
{
|
|
|
578 |
if (!is_dir($sourceDirectory)) {
|
|
|
579 |
throw new \InvalidArgumentException(sprintf('Source directory %s does not exist or is not a directory.', $sourceDirectory));
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
if (!is_dir($targetDirectory)) {
|
|
|
583 |
throw new \InvalidArgumentException(sprintf('Target directory %s does not exist or is not a directory.', $targetDirectory));
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
if ($sourceDirectory == $targetDirectory) {
|
|
|
587 |
throw new \InvalidArgumentException('Source and target directories must differ.');
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
// Drop . and .. and reset array keys
|
|
|
591 |
$files = array_filter(array_values(array_diff(scandir($sourceDirectory), ['.', '..'])), static function ($file) use ($sourceDirectory) {
|
|
|
592 |
return is_file($sourceDirectory . DIRECTORY_SEPARATOR . $file) && is_readable($sourceDirectory . DIRECTORY_SEPARATOR . $file);
|
|
|
593 |
});
|
|
|
594 |
|
|
|
595 |
if (empty($files)) {
|
|
|
596 |
throw new \InvalidArgumentException(sprintf('Source directory %s is empty.', $sourceDirectory));
|
|
|
597 |
}
|
|
|
598 |
|
|
|
599 |
$sourceFullPath = $sourceDirectory . DIRECTORY_SEPARATOR . static::randomElement($files);
|
|
|
600 |
|
|
|
601 |
$destinationFile = Uuid::uuid() . '.' . pathinfo($sourceFullPath, PATHINFO_EXTENSION);
|
|
|
602 |
$destinationFullPath = $targetDirectory . DIRECTORY_SEPARATOR . $destinationFile;
|
|
|
603 |
|
|
|
604 |
if (false === copy($sourceFullPath, $destinationFullPath)) {
|
|
|
605 |
return false;
|
|
|
606 |
}
|
|
|
607 |
|
|
|
608 |
return $fullPath ? $destinationFullPath : $destinationFile;
|
|
|
609 |
}
|
|
|
610 |
}
|