FileStorage.php 60 KB

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