File.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Downloadable\Helper;
  7. use Magento\Framework\App\Filesystem\DirectoryList;
  8. /**
  9. * Downloadable Products File Helper
  10. *
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class File extends \Magento\Framework\App\Helper\AbstractHelper
  15. {
  16. /**
  17. * Core file storage database
  18. *
  19. * @var \Magento\MediaStorage\Helper\File\Storage\Database
  20. */
  21. protected $_coreFileStorageDatabase = null;
  22. /**
  23. * Filesystem object.
  24. *
  25. * @var \Magento\Framework\Filesystem
  26. */
  27. protected $_filesystem;
  28. /**
  29. * Media Directory object (writable).
  30. *
  31. * @var \Magento\Framework\Filesystem\Directory\WriteInterface
  32. */
  33. protected $_mediaDirectory;
  34. /**
  35. * @param \Magento\Framework\App\Helper\Context $context
  36. * @param \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase
  37. * @param \Magento\Framework\Filesystem $filesystem
  38. * @param array $mimeTypes
  39. */
  40. public function __construct(
  41. \Magento\Framework\App\Helper\Context $context,
  42. \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase,
  43. \Magento\Framework\Filesystem $filesystem,
  44. array $mimeTypes = []
  45. ) {
  46. $this->_coreFileStorageDatabase = $coreFileStorageDatabase;
  47. $this->_filesystem = $filesystem;
  48. $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
  49. parent::__construct($context);
  50. if (!empty($mimeTypes)) {
  51. foreach ($mimeTypes as $key => $value) {
  52. self::$_mimeTypes[$key] = $value;
  53. }
  54. }
  55. }
  56. /**
  57. * Upload file from temporary folder.
  58. * @param string $tmpPath
  59. * @param \Magento\MediaStorage\Model\File\Uploader $uploader
  60. * @return array
  61. */
  62. public function uploadFromTmp($tmpPath, \Magento\MediaStorage\Model\File\Uploader $uploader)
  63. {
  64. $uploader->setAllowRenameFiles(true);
  65. $uploader->setFilesDispersion(true);
  66. $absoluteTmpPath = $this->_mediaDirectory->getAbsolutePath($tmpPath);
  67. $result = $uploader->save($absoluteTmpPath);
  68. unset($result['path']);
  69. return $result;
  70. }
  71. /**
  72. * Checking file for moving and move it
  73. * @param string $baseTmpPath
  74. * @param string $basePath
  75. * @param string $file
  76. * @return string
  77. * @throws \Magento\Framework\Exception\LocalizedException
  78. */
  79. public function moveFileFromTmp($baseTmpPath, $basePath, $file)
  80. {
  81. if (isset($file[0])) {
  82. $fileName = $file[0]['file'];
  83. if ($file[0]['status'] === 'new') {
  84. try {
  85. $fileName = $this->_moveFileFromTmp($baseTmpPath, $basePath, $file[0]['file']);
  86. } catch (\Exception $e) {
  87. throw new \Magento\Framework\Exception\LocalizedException(
  88. __('Something went wrong while saving the file(s).')
  89. );
  90. }
  91. }
  92. return $fileName;
  93. }
  94. return '';
  95. }
  96. /**
  97. * Check if file exist in filesystem and try to re-create it from database record if negative.
  98. * @param string $file
  99. * @return bool|int
  100. */
  101. public function ensureFileInFilesystem($file)
  102. {
  103. $result = true;
  104. if (!$this->_mediaDirectory->isFile($file)) {
  105. $result = $this->_coreFileStorageDatabase->saveFileToFilesystem($file);
  106. }
  107. return $result;
  108. }
  109. /**
  110. * Move file from tmp path to base path
  111. *
  112. * @param string $baseTmpPath
  113. * @param string $basePath
  114. * @param string $file
  115. * @return string
  116. */
  117. protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
  118. {
  119. if (strrpos($file, '.tmp') == strlen($file) - 4) {
  120. $file = substr($file, 0, strlen($file) - 4);
  121. }
  122. $destFile = dirname(
  123. $file
  124. ) . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName(
  125. $this->getFilePath($basePath, $file)
  126. );
  127. $this->_coreFileStorageDatabase->copyFile(
  128. $this->getFilePath($baseTmpPath, $file),
  129. $this->getFilePath($basePath, $destFile)
  130. );
  131. $this->_mediaDirectory->renameFile(
  132. $this->getFilePath($baseTmpPath, $file),
  133. $this->getFilePath($basePath, $destFile)
  134. );
  135. return str_replace('\\', '/', $destFile);
  136. }
  137. /**
  138. * Return full path to file
  139. *
  140. * @param string $path
  141. * @param string $file
  142. * @return string
  143. */
  144. public function getFilePath($path, $file)
  145. {
  146. $path = rtrim($path, '/');
  147. $file = ltrim($file, '/');
  148. return $path . '/' . $file;
  149. }
  150. /**
  151. * Return file name form file path
  152. *
  153. * @param string $pathFile
  154. * @return string
  155. */
  156. public function getFileFromPathFile($pathFile)
  157. {
  158. $file = substr($pathFile, strrpos($pathFile, '/') + 1);
  159. return $file;
  160. }
  161. /**
  162. * Get filesize in bytes.
  163. * @param string $file
  164. * @return int
  165. */
  166. public function getFileSize($file)
  167. {
  168. return $this->_mediaDirectory->stat($file)['size'];
  169. }
  170. /**
  171. * @param string $filePath
  172. * @return string
  173. */
  174. public function getFileType($filePath)
  175. {
  176. $ext = substr($filePath, strrpos($filePath, '.') + 1);
  177. return $this->_getFileTypeByExt($ext);
  178. }
  179. /**
  180. * @param string $ext
  181. * @return string
  182. */
  183. protected function _getFileTypeByExt($ext)
  184. {
  185. $type = 'x' . $ext;
  186. if (isset(self::$_mimeTypes[$type])) {
  187. return self::$_mimeTypes[$type];
  188. }
  189. return 'application/octet-stream';
  190. }
  191. /**
  192. * @return array
  193. */
  194. public function getAllFileTypes()
  195. {
  196. return array_values(self::getAllMineTypes());
  197. }
  198. /**
  199. * @return array
  200. */
  201. public function getAllMineTypes()
  202. {
  203. return self::$_mimeTypes;
  204. }
  205. /**
  206. * @var array
  207. */
  208. protected static $_mimeTypes = [
  209. 'x123' => 'application/vnd.lotus-1-2-3',
  210. 'x3dml' => 'text/vnd.in3d.3dml',
  211. 'x3g2' => 'video/3gpp2',
  212. 'x3gp' => 'video/3gpp',
  213. 'xace' => 'application/x-ace-compressed',
  214. 'xacu' => 'application/vnd.acucobol',
  215. 'xaep' => 'application/vnd.audiograph',
  216. 'xai' => 'application/postscript',
  217. 'xaif' => 'audio/x-aiff',
  218. 'xaifc' => 'audio/x-aiff',
  219. 'xaiff' => 'audio/x-aiff',
  220. 'xami' => 'application/vnd.amiga.ami',
  221. 'xapr' => 'application/vnd.lotus-approach',
  222. 'xasf' => 'video/x-ms-asf',
  223. 'xaso' => 'application/vnd.accpac.simply.aso',
  224. 'xasx' => 'video/x-ms-asf',
  225. 'xatom' => 'application/atom+xml',
  226. 'xatomcat' => 'application/atomcat+xml',
  227. 'xatomsvc' => 'application/atomsvc+xml',
  228. 'xatx' => 'application/vnd.antix.game-component',
  229. 'xau' => 'audio/basic',
  230. 'xavi' => 'video/x-msvideo',
  231. 'xbat' => 'application/x-msdownload',
  232. 'xbcpio' => 'application/x-bcpio',
  233. 'xbdm' => 'application/vnd.syncml.dm+wbxml',
  234. 'xbh2' => 'application/vnd.fujitsu.oasysprs',
  235. 'xbmi' => 'application/vnd.bmi',
  236. 'xbmp' => 'image/bmp',
  237. 'xbox' => 'application/vnd.previewsystems.box',
  238. 'xboz' => 'application/x-bzip2',
  239. 'xbtif' => 'image/prs.btif',
  240. 'xbz' => 'application/x-bzip',
  241. 'xbz2' => 'application/x-bzip2',
  242. 'xcab' => 'application/vnd.ms-cab-compressed',
  243. 'xccxml' => 'application/ccxml+xml',
  244. 'xcdbcmsg' => 'application/vnd.contact.cmsg',
  245. 'xcdkey' => 'application/vnd.mediastation.cdkey',
  246. 'xcdx' => 'chemical/x-cdx',
  247. 'xcdxml' => 'application/vnd.chemdraw+xml',
  248. 'xcdy' => 'application/vnd.cinderella',
  249. 'xcer' => 'application/pkix-cert',
  250. 'xcgm' => 'image/cgm',
  251. 'xchat' => 'application/x-chat',
  252. 'xchm' => 'application/vnd.ms-htmlhelp',
  253. 'xchrt' => 'application/vnd.kde.kchart',
  254. 'xcif' => 'chemical/x-cif',
  255. 'xcii' => 'application/vnd.anser-web-certificate-issue-initiation',
  256. 'xcil' => 'application/vnd.ms-artgalry',
  257. 'xcla' => 'application/vnd.claymore',
  258. 'xclkk' => 'application/vnd.crick.clicker.keyboard',
  259. 'xclkp' => 'application/vnd.crick.clicker.palette',
  260. 'xclkt' => 'application/vnd.crick.clicker.template',
  261. 'xclkw' => 'application/vnd.crick.clicker.wordbank',
  262. 'xclkx' => 'application/vnd.crick.clicker',
  263. 'xclp' => 'application/x-msclip',
  264. 'xcmc' => 'application/vnd.cosmocaller',
  265. 'xcmdf' => 'chemical/x-cmdf',
  266. 'xcml' => 'chemical/x-cml',
  267. 'xcmp' => 'application/vnd.yellowriver-custom-menu',
  268. 'xcmx' => 'image/x-cmx',
  269. 'xcom' => 'application/x-msdownload',
  270. 'xconf' => 'text/plain',
  271. 'xcpio' => 'application/x-cpio',
  272. 'xcpt' => 'application/mac-compactpro',
  273. 'xcrd' => 'application/x-mscardfile',
  274. 'xcrl' => 'application/pkix-crl',
  275. 'xcrt' => 'application/x-x509-ca-cert',
  276. 'xcsh' => 'application/x-csh',
  277. 'xcsml' => 'chemical/x-csml',
  278. 'xcss' => 'text/css',
  279. 'xcsv' => 'text/csv',
  280. 'xcurl' => 'application/vnd.curl',
  281. 'xcww' => 'application/prs.cww',
  282. 'xdaf' => 'application/vnd.mobius.daf',
  283. 'xdavmount' => 'application/davmount+xml',
  284. 'xdd2' => 'application/vnd.oma.dd2+xml',
  285. 'xddd' => 'application/vnd.fujixerox.ddd',
  286. 'xdef' => 'text/plain',
  287. 'xder' => 'application/x-x509-ca-cert',
  288. 'xdfac' => 'application/vnd.dreamfactory',
  289. 'xdis' => 'application/vnd.mobius.dis',
  290. 'xdjv' => 'image/vnd.djvu',
  291. 'xdjvu' => 'image/vnd.djvu',
  292. 'xdll' => 'application/x-msdownload',
  293. 'xdna' => 'application/vnd.dna',
  294. 'xdoc' => 'application/msword',
  295. 'xdot' => 'application/msword',
  296. 'xdp' => 'application/vnd.osgi.dp',
  297. 'xdpg' => 'application/vnd.dpgraph',
  298. 'xdsc' => 'text/prs.lines.tag',
  299. 'xdtd' => 'application/xml-dtd',
  300. 'xdvi' => 'application/x-dvi',
  301. 'xdwf' => 'model/vnd.dwf',
  302. 'xdwg' => 'image/vnd.dwg',
  303. 'xdxf' => 'image/vnd.dxf',
  304. 'xdxp' => 'application/vnd.spotfire.dxp',
  305. 'xecelp4800' => 'audio/vnd.nuera.ecelp4800',
  306. 'xecelp7470' => 'audio/vnd.nuera.ecelp7470',
  307. 'xecelp9600' => 'audio/vnd.nuera.ecelp9600',
  308. 'xecma' => 'application/ecmascript',
  309. 'xedm' => 'application/vnd.novadigm.edm',
  310. 'xedx' => 'application/vnd.novadigm.edx',
  311. 'xefif' => 'application/vnd.picsel',
  312. 'xei6' => 'application/vnd.pg.osasli',
  313. 'xeml' => 'message/rfc822',
  314. 'xeol' => 'audio/vnd.digital-winds',
  315. 'xeot' => 'application/vnd.ms-fontobject',
  316. 'xeps' => 'application/postscript',
  317. 'xesf' => 'application/vnd.epson.esf',
  318. 'xetx' => 'text/x-setext',
  319. 'xexe' => 'application/x-msdownload',
  320. 'xext' => 'application/vnd.novadigm.ext',
  321. 'xez' => 'application/andrew-inset',
  322. 'xez2' => 'application/vnd.ezpix-album',
  323. 'xez3' => 'application/vnd.ezpix-package',
  324. 'xfbs' => 'image/vnd.fastbidsheet',
  325. 'xfdf' => 'application/vnd.fdf',
  326. 'xfe_launch' => 'application/vnd.denovo.fcselayout-link',
  327. 'xfg5' => 'application/vnd.fujitsu.oasysgp',
  328. 'xfli' => 'video/x-fli',
  329. 'xflo' => 'application/vnd.micrografx.flo',
  330. 'xflw' => 'application/vnd.kde.kivio',
  331. 'xflx' => 'text/vnd.fmi.flexstor',
  332. 'xfly' => 'text/vnd.fly',
  333. 'xfnc' => 'application/vnd.frogans.fnc',
  334. 'xfpx' => 'image/vnd.fpx',
  335. 'xfsc' => 'application/vnd.fsc.weblaunch',
  336. 'xfst' => 'image/vnd.fst',
  337. 'xftc' => 'application/vnd.fluxtime.clip',
  338. 'xfti' => 'application/vnd.anser-web-funds-transfer-initiation',
  339. 'xfvt' => 'video/vnd.fvt',
  340. 'xfzs' => 'application/vnd.fuzzysheet',
  341. 'xg3' => 'image/g3fax',
  342. 'xgac' => 'application/vnd.groove-account',
  343. 'xgdl' => 'model/vnd.gdl',
  344. 'xghf' => 'application/vnd.groove-help',
  345. 'xgif' => 'image/gif',
  346. 'xgim' => 'application/vnd.groove-identity-message',
  347. 'xgph' => 'application/vnd.flographit',
  348. 'xgram' => 'application/srgs',
  349. 'xgrv' => 'application/vnd.groove-injector',
  350. 'xgrxml' => 'application/srgs+xml',
  351. 'xgtar' => 'application/x-gtar',
  352. 'xgtm' => 'application/vnd.groove-tool-message',
  353. 'xgtw' => 'model/vnd.gtw',
  354. 'xh261' => 'video/h261',
  355. 'xh263' => 'video/h263',
  356. 'xh264' => 'video/h264',
  357. 'xhbci' => 'application/vnd.hbci',
  358. 'xhdf' => 'application/x-hdf',
  359. 'xhlp' => 'application/winhlp',
  360. 'xhpgl' => 'application/vnd.hp-hpgl',
  361. 'xhpid' => 'application/vnd.hp-hpid',
  362. 'xhps' => 'application/vnd.hp-hps',
  363. 'xhqx' => 'application/mac-binhex40',
  364. 'xhtke' => 'application/vnd.kenameaapp',
  365. 'xhtm' => 'text/html',
  366. 'xhtml' => 'text/html',
  367. 'xhvd' => 'application/vnd.yamaha.hv-dic',
  368. 'xhvp' => 'application/vnd.yamaha.hv-voice',
  369. 'xhvs' => 'application/vnd.yamaha.hv-script',
  370. 'xice' => '#x-conference/x-cooltalk',
  371. 'xico' => 'image/x-icon',
  372. 'xics' => 'text/calendar',
  373. 'xief' => 'image/ief',
  374. 'xifb' => 'text/calendar',
  375. 'xifm' => 'application/vnd.shana.informed.formdata',
  376. 'xigl' => 'application/vnd.igloader',
  377. 'xigx' => 'application/vnd.micrografx.igx',
  378. 'xiif' => 'application/vnd.shana.informed.interchange',
  379. 'ximp' => 'application/vnd.accpac.simply.imp',
  380. 'xims' => 'application/vnd.ms-ims',
  381. 'xin' => 'text/plain',
  382. 'xipk' => 'application/vnd.shana.informed.package',
  383. 'xirm' => 'application/vnd.ibm.rights-management',
  384. 'xirp' => 'application/vnd.irepository.package+xml',
  385. 'xitp' => 'application/vnd.shana.informed.formtemplate',
  386. 'xivp' => 'application/vnd.immervision-ivp',
  387. 'xivu' => 'application/vnd.immervision-ivu',
  388. 'xjad' => 'text/vnd.sun.j2me.app-descriptor',
  389. 'xjam' => 'application/vnd.jam',
  390. 'xjava' => 'text/x-java-source',
  391. 'xjisp' => 'application/vnd.jisp',
  392. 'xjlt' => 'application/vnd.hp-jlyt',
  393. 'xjoda' => 'application/vnd.joost.joda-archive',
  394. 'xjpe' => 'image/jpeg',
  395. 'xjpeg' => 'image/jpeg',
  396. 'xjpg' => 'image/jpeg',
  397. 'xjpgm' => 'video/jpm',
  398. 'xjpgv' => 'video/jpeg',
  399. 'xjpm' => 'video/jpm',
  400. 'xjs' => 'application/javascript',
  401. 'xjson' => 'application/json',
  402. 'xkar' => 'audio/midi',
  403. 'xkarbon' => 'application/vnd.kde.karbon',
  404. 'xkfo' => 'application/vnd.kde.kformula',
  405. 'xkia' => 'application/vnd.kidspiration',
  406. 'xkml' => 'application/vnd.google-earth.kml+xml',
  407. 'xkmz' => 'application/vnd.google-earth.kmz',
  408. 'xkon' => 'application/vnd.kde.kontour',
  409. 'xksp' => 'application/vnd.kde.kspread',
  410. 'xlatex' => 'application/x-latex',
  411. 'xlbd' => 'application/vnd.llamagraphics.life-balance.desktop',
  412. 'xlbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml',
  413. 'xles' => 'application/vnd.hhe.lesson-player',
  414. 'xlist' => 'text/plain',
  415. 'xlog' => 'text/plain',
  416. 'xlrm' => 'application/vnd.ms-lrm',
  417. 'xltf' => 'application/vnd.frogans.ltf',
  418. 'xlvp' => 'audio/vnd.lucent.voice',
  419. 'xlwp' => 'application/vnd.lotus-wordpro',
  420. 'xm13' => 'application/x-msmediaview',
  421. 'xm14' => 'application/x-msmediaview',
  422. 'xm1v' => 'video/mpeg',
  423. 'xm2a' => 'audio/mpeg',
  424. 'xm3a' => 'audio/mpeg',
  425. 'xm3u' => 'audio/x-mpegurl',
  426. 'xm4u' => 'video/vnd.mpegurl',
  427. 'xmag' => 'application/vnd.ecowin.chart',
  428. 'xmathml' => 'application/mathml+xml',
  429. 'xmbk' => 'application/vnd.mobius.mbk',
  430. 'xmbox' => 'application/mbox',
  431. 'xmc1' => 'application/vnd.medcalcdata',
  432. 'xmcd' => 'application/vnd.mcd',
  433. 'xmdb' => 'application/x-msaccess',
  434. 'xmdi' => 'image/vnd.ms-modi',
  435. 'xmesh' => 'model/mesh',
  436. 'xmfm' => 'application/vnd.mfmp',
  437. 'xmgz' => 'application/vnd.proteus.magazine',
  438. 'xmid' => 'audio/midi',
  439. 'xmidi' => 'audio/midi',
  440. 'xmif' => 'application/vnd.mif',
  441. 'xmime' => 'message/rfc822',
  442. 'xmj2' => 'video/mj2',
  443. 'xmjp2' => 'video/mj2',
  444. 'xmlp' => 'application/vnd.dolby.mlp',
  445. 'xmmd' => 'application/vnd.chipnuts.karaoke-mmd',
  446. 'xmmf' => 'application/vnd.smaf',
  447. 'xmmr' => 'image/vnd.fujixerox.edmics-mmr',
  448. 'xmny' => 'application/x-msmoney',
  449. 'xmov' => 'video/quicktime',
  450. 'xmovie' => 'video/x-sgi-movie',
  451. 'xmp2' => 'audio/mpeg',
  452. 'xmp2a' => 'audio/mpeg',
  453. 'xmp3' => 'audio/mpeg',
  454. 'xmp4' => 'video/mp4',
  455. 'xmp4a' => 'audio/mp4',
  456. 'xmp4s' => 'application/mp4',
  457. 'xmp4v' => 'video/mp4',
  458. 'xmpc' => 'application/vnd.mophun.certificate',
  459. 'xmpe' => 'video/mpeg',
  460. 'xmpeg' => 'video/mpeg',
  461. 'xmpg' => 'video/mpeg',
  462. 'xmpg4' => 'video/mp4',
  463. 'xmpga' => 'audio/mpeg',
  464. 'xmpkg' => 'application/vnd.apple.installer+xml',
  465. 'xmpm' => 'application/vnd.blueice.multipass',
  466. 'xmpn' => 'application/vnd.mophun.application',
  467. 'xmpp' => 'application/vnd.ms-project',
  468. 'xmpt' => 'application/vnd.ms-project',
  469. 'xmpy' => 'application/vnd.ibm.minipay',
  470. 'xmqy' => 'application/vnd.mobius.mqy',
  471. 'xmrc' => 'application/marc',
  472. 'xmscml' => 'application/mediaservercontrol+xml',
  473. 'xmseq' => 'application/vnd.mseq',
  474. 'xmsf' => 'application/vnd.epson.msf',
  475. 'xmsh' => 'model/mesh',
  476. 'xmsi' => 'application/x-msdownload',
  477. 'xmsl' => 'application/vnd.mobius.msl',
  478. 'xmsty' => 'application/vnd.muvee.style',
  479. 'xmts' => 'model/vnd.mts',
  480. 'xmus' => 'application/vnd.musician',
  481. 'xmvb' => 'application/x-msmediaview',
  482. 'xmwf' => 'application/vnd.mfer',
  483. 'xmxf' => 'application/mxf',
  484. 'xmxl' => 'application/vnd.recordare.musicxml',
  485. 'xmxml' => 'application/xv+xml',
  486. 'xmxs' => 'application/vnd.triscape.mxs',
  487. 'xmxu' => 'video/vnd.mpegurl',
  488. 'xn-gage' => 'application/vnd.nokia.n-gage.symbian.install',
  489. 'xngdat' => 'application/vnd.nokia.n-gage.data',
  490. 'xnlu' => 'application/vnd.neurolanguage.nlu',
  491. 'xnml' => 'application/vnd.enliven',
  492. 'xnnd' => 'application/vnd.noblenet-directory',
  493. 'xnns' => 'application/vnd.noblenet-sealer',
  494. 'xnnw' => 'application/vnd.noblenet-web',
  495. 'xnpx' => 'image/vnd.net-fpx',
  496. 'xnsf' => 'application/vnd.lotus-notes',
  497. 'xoa2' => 'application/vnd.fujitsu.oasys2',
  498. 'xoa3' => 'application/vnd.fujitsu.oasys3',
  499. 'xoas' => 'application/vnd.fujitsu.oasys',
  500. 'xobd' => 'application/x-msbinder',
  501. 'xoda' => 'application/oda',
  502. 'xodc' => 'application/vnd.oasis.opendocument.chart',
  503. 'xodf' => 'application/vnd.oasis.opendocument.formula',
  504. 'xodg' => 'application/vnd.oasis.opendocument.graphics',
  505. 'xodi' => 'application/vnd.oasis.opendocument.image',
  506. 'xodp' => 'application/vnd.oasis.opendocument.presentation',
  507. 'xods' => 'application/vnd.oasis.opendocument.spreadsheet',
  508. 'xodt' => 'application/vnd.oasis.opendocument.text',
  509. 'xogg' => 'application/ogg',
  510. 'xoprc' => 'application/vnd.palm',
  511. 'xorg' => 'application/vnd.lotus-organizer',
  512. 'xotc' => 'application/vnd.oasis.opendocument.chart-template',
  513. 'xotf' => 'application/vnd.oasis.opendocument.formula-template',
  514. 'xotg' => 'application/vnd.oasis.opendocument.graphics-template',
  515. 'xoth' => 'application/vnd.oasis.opendocument.text-web',
  516. 'xoti' => 'application/vnd.oasis.opendocument.image-template',
  517. 'xotm' => 'application/vnd.oasis.opendocument.text-master',
  518. 'xots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
  519. 'xott' => 'application/vnd.oasis.opendocument.text-template',
  520. 'xoxt' => 'application/vnd.openofficeorg.extension',
  521. 'xp10' => 'application/pkcs10',
  522. 'xp7r' => 'application/x-pkcs7-certreqresp',
  523. 'xp7s' => 'application/pkcs7-signature',
  524. 'xpbd' => 'application/vnd.powerbuilder6',
  525. 'xpbm' => 'image/x-portable-bitmap',
  526. 'xpcl' => 'application/vnd.hp-pcl',
  527. 'xpclxl' => 'application/vnd.hp-pclxl',
  528. 'xpct' => 'image/x-pict',
  529. 'xpcx' => 'image/x-pcx',
  530. 'xpdb' => 'chemical/x-pdb',
  531. 'xpdf' => 'application/pdf',
  532. 'xpfr' => 'application/font-tdpfr',
  533. 'xpgm' => 'image/x-portable-graymap',
  534. 'xpgn' => 'application/x-chess-pgn',
  535. 'xpgp' => 'application/pgp-encrypted',
  536. 'xpic' => 'image/x-pict',
  537. 'xpki' => 'application/pkixcmp',
  538. 'xpkipath' => 'application/pkix-pkipath',
  539. 'xplb' => 'application/vnd.3gpp.pic-bw-large',
  540. 'xplc' => 'application/vnd.mobius.plc',
  541. 'xplf' => 'application/vnd.pocketlearn',
  542. 'xpls' => 'application/pls+xml',
  543. 'xpml' => 'application/vnd.ctc-posml',
  544. 'xpng' => 'image/png',
  545. 'xpnm' => 'image/x-portable-anymap',
  546. 'xportpkg' => 'application/vnd.macports.portpkg',
  547. 'xpot' => 'application/vnd.ms-powerpoint',
  548. 'xppd' => 'application/vnd.cups-ppd',
  549. 'xppm' => 'image/x-portable-pixmap',
  550. 'xpps' => 'application/vnd.ms-powerpoint',
  551. 'xppt' => 'application/vnd.ms-powerpoint',
  552. 'xpqa' => 'application/vnd.palm',
  553. 'xprc' => 'application/vnd.palm',
  554. 'xpre' => 'application/vnd.lotus-freelance',
  555. 'xprf' => 'application/pics-rules',
  556. 'xps' => 'application/postscript',
  557. 'xpsb' => 'application/vnd.3gpp.pic-bw-small',
  558. 'xpsd' => 'image/vnd.adobe.photoshop',
  559. 'xptid' => 'application/vnd.pvi.ptid1',
  560. 'xpub' => 'application/x-mspublisher',
  561. 'xpvb' => 'application/vnd.3gpp.pic-bw-var',
  562. 'xpwn' => 'application/vnd.3m.post-it-notes',
  563. 'xqam' => 'application/vnd.epson.quickanime',
  564. 'xqbo' => 'application/vnd.intu.qbo',
  565. 'xqfx' => 'application/vnd.intu.qfx',
  566. 'xqps' => 'application/vnd.publishare-delta-tree',
  567. 'xqt' => 'video/quicktime',
  568. 'xra' => 'audio/x-pn-realaudio',
  569. 'xram' => 'audio/x-pn-realaudio',
  570. 'xrar' => 'application/x-rar-compressed',
  571. 'xras' => 'image/x-cmu-raster',
  572. 'xrcprofile' => 'application/vnd.ipunplugged.rcprofile',
  573. 'xrdf' => 'application/rdf+xml',
  574. 'xrdz' => 'application/vnd.data-vision.rdz',
  575. 'xrep' => 'application/vnd.businessobjects',
  576. 'xrgb' => 'image/x-rgb',
  577. 'xrif' => 'application/reginfo+xml',
  578. 'xrl' => 'application/resource-lists+xml',
  579. 'xrlc' => 'image/vnd.fujixerox.edmics-rlc',
  580. 'xrm' => 'application/vnd.rn-realmedia',
  581. 'xrmi' => 'audio/midi',
  582. 'xrmp' => 'audio/x-pn-realaudio-plugin',
  583. 'xrms' => 'application/vnd.jcp.javame.midlet-rms',
  584. 'xrnc' => 'application/relax-ng-compact-syntax',
  585. 'xrpss' => 'application/vnd.nokia.radio-presets',
  586. 'xrpst' => 'application/vnd.nokia.radio-preset',
  587. 'xrq' => 'application/sparql-query',
  588. 'xrs' => 'application/rls-services+xml',
  589. 'xrsd' => 'application/rsd+xml',
  590. 'xrss' => 'application/rss+xml',
  591. 'xrtf' => 'application/rtf',
  592. 'xrtx' => 'text/richtext',
  593. 'xsaf' => 'application/vnd.yamaha.smaf-audio',
  594. 'xsbml' => 'application/sbml+xml',
  595. 'xsc' => 'application/vnd.ibm.secure-container',
  596. 'xscd' => 'application/x-msschedule',
  597. 'xscm' => 'application/vnd.lotus-screencam',
  598. 'xscq' => 'application/scvp-cv-request',
  599. 'xscs' => 'application/scvp-cv-response',
  600. 'xsdp' => 'application/sdp',
  601. 'xsee' => 'application/vnd.seemail',
  602. 'xsema' => 'application/vnd.sema',
  603. 'xsemd' => 'application/vnd.semd',
  604. 'xsemf' => 'application/vnd.semf',
  605. 'xsetpay' => 'application/set-payment-initiation',
  606. 'xsetreg' => 'application/set-registration-initiation',
  607. 'xsfs' => 'application/vnd.spotfire.sfs',
  608. 'xsgm' => 'text/sgml',
  609. 'xsgml' => 'text/sgml',
  610. 'xsh' => 'application/x-sh',
  611. 'xshar' => 'application/x-shar',
  612. 'xshf' => 'application/shf+xml',
  613. 'xsilo' => 'model/mesh',
  614. 'xsit' => 'application/x-stuffit',
  615. 'xsitx' => 'application/x-stuffitx',
  616. 'xslt' => 'application/vnd.epson.salt',
  617. 'xsnd' => 'audio/basic',
  618. 'xspf' => 'application/vnd.yamaha.smaf-phrase',
  619. 'xspl' => 'application/x-futuresplash',
  620. 'xspot' => 'text/vnd.in3d.spot',
  621. 'xspp' => 'application/scvp-vp-response',
  622. 'xspq' => 'application/scvp-vp-request',
  623. 'xsrc' => 'application/x-wais-source',
  624. 'xsrx' => 'application/sparql-results+xml',
  625. 'xssf' => 'application/vnd.epson.ssf',
  626. 'xssml' => 'application/ssml+xml',
  627. 'xstf' => 'application/vnd.wt.stf',
  628. 'xstk' => 'application/hyperstudio',
  629. 'xstr' => 'application/vnd.pg.format',
  630. 'xsus' => 'application/vnd.sus-calendar',
  631. 'xsusp' => 'application/vnd.sus-calendar',
  632. 'xsv4cpio' => 'application/x-sv4cpio',
  633. 'xsv4crc' => 'application/x-sv4crc',
  634. 'xsvd' => 'application/vnd.svd',
  635. 'xswf' => 'application/x-shockwave-flash',
  636. 'xtao' => 'application/vnd.tao.intent-module-archive',
  637. 'xtar' => 'application/x-tar',
  638. 'xtcap' => 'application/vnd.3gpp2.tcap',
  639. 'xtcl' => 'application/x-tcl',
  640. 'xtex' => 'application/x-tex',
  641. 'xtext' => 'text/plain',
  642. 'xtif' => 'image/tiff',
  643. 'xtiff' => 'image/tiff',
  644. 'xtmo' => 'application/vnd.tmobile-livetv',
  645. 'xtorrent' => 'application/x-bittorrent',
  646. 'xtpl' => 'application/vnd.groove-tool-template',
  647. 'xtpt' => 'application/vnd.trid.tpt',
  648. 'xtra' => 'application/vnd.trueapp',
  649. 'xtrm' => 'application/x-msterminal',
  650. 'xtsv' => 'text/tab-separated-values',
  651. 'xtxd' => 'application/vnd.genomatix.tuxedo',
  652. 'xtxf' => 'application/vnd.mobius.txf',
  653. 'xtxt' => 'text/plain',
  654. 'xumj' => 'application/vnd.umajin',
  655. 'xunityweb' => 'application/vnd.unity',
  656. 'xuoml' => 'application/vnd.uoml+xml',
  657. 'xuri' => 'text/uri-list',
  658. 'xuris' => 'text/uri-list',
  659. 'xurls' => 'text/uri-list',
  660. 'xustar' => 'application/x-ustar',
  661. 'xutz' => 'application/vnd.uiq.theme',
  662. 'xuu' => 'text/x-uuencode',
  663. 'xvcd' => 'application/x-cdlink',
  664. 'xvcf' => 'text/x-vcard',
  665. 'xvcg' => 'application/vnd.groove-vcard',
  666. 'xvcs' => 'text/x-vcalendar',
  667. 'xvcx' => 'application/vnd.vcx',
  668. 'xvis' => 'application/vnd.visionary',
  669. 'xviv' => 'video/vnd.vivo',
  670. 'xvrml' => 'model/vrml',
  671. 'xvsd' => 'application/vnd.visio',
  672. 'xvsf' => 'application/vnd.vsf',
  673. 'xvss' => 'application/vnd.visio',
  674. 'xvst' => 'application/vnd.visio',
  675. 'xvsw' => 'application/vnd.visio',
  676. 'xvtu' => 'model/vnd.vtu',
  677. 'xvxml' => 'application/voicexml+xml',
  678. 'xwav' => 'audio/x-wav',
  679. 'xwax' => 'audio/x-ms-wax',
  680. 'xwbmp' => 'image/vnd.wap.wbmp',
  681. 'xwbs' => 'application/vnd.criticaltools.wbs+xml',
  682. 'xwbxml' => 'application/vnd.wap.wbxml',
  683. 'xwcm' => 'application/vnd.ms-works',
  684. 'xwdb' => 'application/vnd.ms-works',
  685. 'xwks' => 'application/vnd.ms-works',
  686. 'xwm' => 'video/x-ms-wm',
  687. 'xwma' => 'audio/x-ms-wma',
  688. 'xwmd' => 'application/x-ms-wmd',
  689. 'xwmf' => 'application/x-msmetafile',
  690. 'xwml' => 'text/vnd.wap.wml',
  691. 'xwmlc' => 'application/vnd.wap.wmlc',
  692. 'xwmls' => 'text/vnd.wap.wmlscript',
  693. 'xwmlsc' => 'application/vnd.wap.wmlscriptc',
  694. 'xwmv' => 'video/x-ms-wmv',
  695. 'xwmx' => 'video/x-ms-wmx',
  696. 'xwmz' => 'application/x-ms-wmz',
  697. 'xwpd' => 'application/vnd.wordperfect',
  698. 'xwpl' => 'application/vnd.ms-wpl',
  699. 'xwps' => 'application/vnd.ms-works',
  700. 'xwqd' => 'application/vnd.wqd',
  701. 'xwri' => 'application/x-mswrite',
  702. 'xwrl' => 'model/vrml',
  703. 'xwsdl' => 'application/wsdl+xml',
  704. 'xwspolicy' => 'application/wspolicy+xml',
  705. 'xwtb' => 'application/vnd.webturbo',
  706. 'xwvx' => 'video/x-ms-wvx',
  707. 'xx3d' => 'application/vnd.hzn-3d-crossword',
  708. 'xxar' => 'application/vnd.xara',
  709. 'xxbd' => 'application/vnd.fujixerox.docuworks.binder',
  710. 'xxbm' => 'image/x-xbitmap',
  711. 'xxdm' => 'application/vnd.syncml.dm+xml',
  712. 'xxdp' => 'application/vnd.adobe.xdp+xml',
  713. 'xxdw' => 'application/vnd.fujixerox.docuworks',
  714. 'xxenc' => 'application/xenc+xml',
  715. 'xxfdf' => 'application/vnd.adobe.xfdf',
  716. 'xxfdl' => 'application/vnd.xfdl',
  717. 'xxht' => 'application/xhtml+xml',
  718. 'xxhtml' => 'application/xhtml+xml',
  719. 'xxhvml' => 'application/xv+xml',
  720. 'xxif' => 'image/vnd.xiff',
  721. 'xxla' => 'application/vnd.ms-excel',
  722. 'xxlc' => 'application/vnd.ms-excel',
  723. 'xxlm' => 'application/vnd.ms-excel',
  724. 'xxls' => 'application/vnd.ms-excel',
  725. 'xxlt' => 'application/vnd.ms-excel',
  726. 'xxlw' => 'application/vnd.ms-excel',
  727. 'xxml' => 'application/xml',
  728. 'xxo' => 'application/vnd.olpc-sugar',
  729. 'xxop' => 'application/xop+xml',
  730. 'xxpm' => 'image/x-xpixmap',
  731. 'xxpr' => 'application/vnd.is-xpr',
  732. 'xxps' => 'application/vnd.ms-xpsdocument',
  733. 'xxsl' => 'application/xml',
  734. 'xxslt' => 'application/xslt+xml',
  735. 'xxsm' => 'application/vnd.syncml+xml',
  736. 'xxspf' => 'application/xspf+xml',
  737. 'xxul' => 'application/vnd.mozilla.xul+xml',
  738. 'xxvm' => 'application/xv+xml',
  739. 'xxvml' => 'application/xv+xml',
  740. 'xxwd' => 'image/x-xwindowdump',
  741. 'xxyz' => 'chemical/x-xyz',
  742. 'xzaz' => 'application/vnd.zzazz.deck+xml',
  743. 'xzip' => 'application/zip',
  744. 'xzmm' => 'application/vnd.handheld-entertainment+xml'
  745. ];
  746. }