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