| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182 |
- <?php
- // @requires $_SERVER['SERVER_NAME']
- Lib::loadClass('Http');
- /**
- * @example: FileStorage::addFile($binaryContent, $name);
- */
- /*
- # FileStorage:
- - [x] create CRM_FILES - sql at the end of file
- - [x] only meta fields, perms? - no perms in relation based on record which is connected
- - [x] add file to storage - API POST/PUT action
- - [ ] base storage folder - from config - default /Library/Server/Web/Data/p5-pliki, chmod - add to instalator, upgrade
- - [x] subfolders like postfix, but [0-9],[A-Z] - substr(strrev(base_convert($id, 10, 10 + 26)), 0, 1) - 36 folderów
- - [x] file connected to user - A_RECORD_CREATE_AUTHOR
- - [ ] ? file connected to user - A_OWNER (L_APP_USER)?
- - [ ] connect file to record - generate {tbl_name}__#REF__FILES
- - [ ] ? add A_HAS_REF field to struct - cache to check if file is connected to any record
- - [-] add sync state - remote file name, mtime to check if file has changed in Storage or remote record folder
- - [-] sync - conflict - file connected with 2 objects and both changed and try to store changes to FileStorage
- - [ ] add version to REF table
- - [x] use streams for upload - better memory usage
- - [ ] 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/
- - [x] add IP to table struct
- - [ ] 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
- - [ ] Update file - add {tblName}__#VERSIONS table (work like _HIST, but only on update file content)
- */
- class FileStorage {
- public static function isProduction() {// TODO: mv to Config
- // return V::get('P5_ENV', '/Library/Server/Web/Data/p5-file-storage', $_SERVER);
- // $env = getenv('P5_ENV');
- // if (empty($env)) $env = 'production';
- return ('production' == V::get('P5_ENV', 'production', $_SERVER));
- }
- public static function getRootStoragePath() {
- return (self::isProduction()) ? '/Library/Server/Web/Data/p5-file-storage' : '/tmp/test-upload-file-storage';
- }
- public static function getTableName() {
- return (self::isProduction()) ? 'CRM_FILES' : 'CRM_FILES__#DEV';
- }
- public static function getFileById($idFile, $forceVersion = null) {
- $fileObject = array();// @returns array
- $fileObject['_raw'] = null;// raw object from database
- $fileObject['id'] = (int)$idFile;
- $fileObject['name'] = '';
- $fileObject['relativePath'] = null;
- $fileObject['absolutePath'] = null;
- $fileObject['exists'] = null;
- $fileObject['size'] = 0;
- $fileObject['mimeType'] = null;
- $fileObject['version'] = 0;
- $rowFile = self::_getRowFile($idFile, $forceVersion);
- $fileObject['_raw'] = $rowFile;
- // TODO: check perms
- $fileObject['name'] = V::get('FILE_LABEL', $id, $rowFile);
- $fileObject['version'] = ($forceVersion) ? $forceVersion : V::get('FILE_VERSION', 0, $rowFile);
- $fileObject['relativePath'] = self::generateFilePathHashFromId($rowFile['ID'], $version);
- $fileObject['absolutePath'] = self::getRootStoragePath() . "/" . $fileObject['relativePath'];
- $fileObject['exists'] = file_exists($fileObject['absolutePath']);
- if ($fileObject['exists']) {
- $fileObject['size'] = ($rowFile['FILE_SIZE']) ? $rowFile['FILE_SIZE'] : filesize($absFilePath);
- $fileObject['mimeType'] = ($rowFile['FILE_MIME_TYPE']) ? $rowFile['FILE_MIME_TYPE'] : mime_content_type($absFilePath);
- }
- return $fileObject;
- }
- public static function addFileStream($inputHandler, $name = '') {
- $sqlLogin = User::getLogin();
- $sqlIP = Request::getUserIp();
- $sqlLabel = DB::getPDO()->quote($name, PDO::PARAM_STR);
- $idFile = self::_createRowFile($name);
- DBG::_('DBG', '>1', "idFile", $idFile, __CLASS__, __FUNCTION__, __LINE__);
- $fileObject = self::getFileById($idFile);
- $absFilePath = $fileObject['absolutePath'];
- $dirPath = dirname($absFilePath);
- @mkdir($dirPath, $mode = 0775, $recursive = true);
- if (!file_exists($dirPath)) throw new HttpException("#L" . __LINE__ . ": Cannot create path", 500);
- @chmod($dirPath, $mode = 0775);
- // create a temp file where to save data from the input stream
- $fileHandler = fopen($absFilePath, "w+");
- DBG::_('DBG', '>1', "absFilePath", $absFilePath, __CLASS__, __FUNCTION__, __LINE__);
- // save data from the input stream
- while (true) {
- $buffer = fgets($inputHandler, 4096);
- if (strlen($buffer) == 0) {
- fclose($inputHandler);
- fclose($fileHandler);
- break;
- }
- fwrite($fileHandler, $buffer);
- }
- if (!file_exists($absFilePath)) throw new Exception("Cannot save file");
- self::_uploadUpdateMimeType($idFile, $absFilePath);
- self::_uploadUpdateStat($idFile, $absFilePath);
- return $idFile;
- }
- public static function addFile($content, $name = '') {
- $rootFileStoragePath = self::getRootStoragePath();
- $idFile = self::_createRowFile($name);
- DBG::_('DBG', '>1', "idFile", $idFile, __CLASS__, __FUNCTION__, __LINE__);
- $fileObject = self::getFileById($idFile);
- $absFilePath = $fileObject['absolutePath'];
- $dirPath = dirname($absFilePath);
- @mkdir($dirPath, $mode = 0777, $recursive = true);
- if (!file_exists($dirPath)) throw new Exception("Cannot create path");
- @chmod($dirPath, $mode = 0777);
- $fp = fopen($absFilePath, 'w');
- fwrite($fp, $content);
- fclose($fp);
- if (!file_exists($absFilePath)) throw new Exception("Cannot save file");
- self::_uploadUpdateMimeType($idFile, $absFilePath);
- self::_uploadUpdateStat($idFile, $absFilePath);
- return $idFile;
- }
- public static function updateFileStream($idFile, $inputHandler, $name = '') {
- throw new Exception("TODO: insert into `\{\$tblName\}__#VERSIONS` for file `{$idFile}`");
- $fileObject = self::getFileById($idFile);
- if (!$fileObject['exists']) throw new Exception("Oryginalny plik nie istnieje");
- // TODO: check perms
- $fileVersion = self::_createUpdateRowFile($idFile, $name);// insert into `{$tblName}__#VERSIONS` ( `FILE_VERSION` = 1 + (select MAX(`FILE_VERSION`) from #VER) )
- {// upload by stream
- }
- self::_updateRowFileFromVersion($fileVersion);// update `{$tblName}` values from `{$tblName}__#VERSIONS`
- }
- public static function _createRowFile($name = '') {
- $sqlLogin = User::getLogin();
- $sqlLabel = DB::getPDO()->quote($name, PDO::PARAM_STR);
- $sqlIP = DB::getPDO()->quote(Request::getUserIp(), PDO::PARAM_STR);
- $sqlTblName = self::getTableName();
- $sql = "
- insert into `{$sqlTblName}` (`A_RECORD_CREATE_AUTHOR`,`A_RECORD_CREATE_DATE`,`FILE_LABEL`,`A_USER_IP`)
- values ('{$sqlLogin}', NOW(), {$sqlLabel}, INET_ATON({$sqlIP}))
- ";
- DBG::_('DBG', '>2', "sql", $sql, __CLASS__, __FUNCTION__, __LINE__);
- DB::getPDO()->exec($sql);
- return DB::getPDO()->lastInsertId();
- }
- public static function _getRowFile($idFile, $version = null) {
- $idFile = intval($idFile);
- if ($idFile <= 0) throw new HttpException("#L" . __LINE__ . ": Wrong file id", 500);
- $sqlId = DB::getPDO()->quote($idFile, PDO::PARAM_INT);
- $sqlTblName = self::getTableName();
- $rows = DB::getPDO()->fetchAll("
- select f.*
- from `{$sqlTblName}` f
- where f.ID = {$sqlId}
- ");
- DBG::_('DBG', '>2', "rows", $rows, __CLASS__, __FUNCTION__, __LINE__);
- if (empty($rows)) throw new HttpException("Plik nie istnieje w bazie", 404);
- $rowFile = $rows[0];
- // TODO: fetch info by $version
- return $rowFile;
- }
- public static function _uploadUpdateMimeType($idFile, $absPath) {
- $mimeType = mime_content_type($absPath);
- $mtime = filemtime($absPath);
- DBG::_('DBG', '>1', "mimeType", $mimeType, __CLASS__, __FUNCTION__, __LINE__);
- if (!self::isAllowedMimeType($mimeType)) {
- $sqlTblName = self::getTableName();
- if ('inode/x-empty' == $mimeType) {// empty file
- DB::getPDO()->exec("
- update `{$sqlTblName}`
- set `A_STATUS` = 'WARNING'
- -- , `A_STATUS_INFO` = ''
- , `FILE_MIME_TYPE` = '{$mimeType}'
- , `FILE_MTIME` = '{$mtime}'
- , `FILE_SIZE` = 0
- where `ID` = '{$idFile}'
- ");
- throw new AlertWarningException("Wgrano pusty plik");
- } else {// non empty, not allowed mime type
- $size = filesize($absPath);
- DB::getPDO()->exec("
- update `{$sqlTblName}`
- set `A_STATUS` = 'DELETED'
- -- , `A_STATUS_INFO` = ''
- , `FILE_MIME_TYPE` = '{$mimeType}'
- , `FILE_MTIME` = '{$mtime}'
- , `FILE_SIZE` = '{$size}'
- where `ID` = '{$idFile}'
- ");
- rename($absPath, "{$absPath}-not-allowed-mime-type");
- throw new Exception("Niedozwolony typ pliku '{$mimeType}'");
- }
- }
- }
- public static function _uploadUpdateStat($idFile, $absPath) {
- $mimeType = mime_content_type($absPath);
- $mtime = filemtime($absPath);
- $size = filesize($absPath);
- DBG::_('DBG', '>1', "mtime", $mtime, __CLASS__, __FUNCTION__, __LINE__);
- DBG::_('DBG', '>1', "size", $size, __CLASS__, __FUNCTION__, __LINE__);
- $sqlTblName = self::getTableName();
- DB::getPDO()->exec("
- update `{$sqlTblName}`
- set `A_STATUS` = 'NORMAL'
- , `FILE_MIME_TYPE` = '{$mimeType}'
- , `FILE_MTIME` = '{$mtime}'
- , `FILE_SIZE` = '{$size}'
- where `ID` = '{$idFile}'
- ");
- }
- public static function generateFilePathHashFromId($intId, $version = null) {
- // $base36Id = base_convert($intId, 10, 10 + 26);// 0-9 + A-Z
- $base36Id = base_convert($intId, 10, 10 + 6);// 0-9 + A-F
- $base36Str = str_pad($base36Id, 10, "0", STR_PAD_LEFT);
- $base36Str = strrev($base36Str);
- $pathParts = array();
- $pathParts[] = substr($base36Str, 0, 2);
- $pathParts[] = substr($base36Str, 2, 2);
- $pathParts[] = substr($base36Str, 4);
- $hashPath = implode("/", $pathParts);
- // echo "ID($intId) converted to ({$base36Id})\t to ({$base36Str})\t to path ({$hashPath})\n";
- // TODO: add $version to file name: .= "-v{$version}"
- return $hashPath;
- }
- public static function reinstall() {
- try {
- DB::getPDO()->exec("
- CREATE TABLE IF NOT EXISTS `CRM_FILES` (
- `ID` int(11) NOT NULL AUTO_INCREMENT,
- `FILE_HASH` varchar(255) NOT NULL, -- generated from ID by hash function - only for cache
- `FILE_LABEL` varchar(255) NOT NULL, -- original file name or system name
- `FILE_TYPE` varchar(32) NOT NULL DEFAULT '', -- $TRG_FILE -> config/.cnf--folders...
- `FILE_MIME_TYPE` varchar(64) NOT NULL DEFAULT '',
- `FILE_MTIME` datetime NOT NULL,
- `FILE_SIZE` bigint NOT NULL DEFAULT 0,
- `FILE_VERSION` int(11) NOT NULL DEFAULT 0, -- used for update
- `A_STATUS` enum('WAITING','NORMAL','MONITOR','OFF_HARD','OFF_SOFT','DELETED','WARNING') NOT NULL DEFAULT 'WAITING',
- `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
- `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
- `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL,
- `A_RECORD_UPDATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
- `A_ADM_COMPANY` varchar(100) NOT NULL DEFAULT '',
- `A_CLASSIFIED` varchar(100) NOT NULL DEFAULT '',
- `A_USER_IP` bigint NOT NULL DEFAULT '0',
- PRIMARY KEY (`ID`),
- KEY `FILE_TYPE` (`FILE_TYPE`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
- ");
- DB::getPDO()->exec("
- CREATE TABLE IF NOT EXISTS `CRM_FILES__#DEV` (
- `ID` int(11) NOT NULL AUTO_INCREMENT,
- `FILE_HASH` varchar(255) NOT NULL, -- generated from ID by hash function - only for cache
- `FILE_LABEL` varchar(255) NOT NULL, -- original file name or system name
- `FILE_TYPE` varchar(32) NOT NULL DEFAULT '', -- $TRG_FILE -> config/.cnf--folders...
- `FILE_MIME_TYPE` varchar(64) NOT NULL DEFAULT '',
- `FILE_MTIME` datetime NOT NULL,
- `FILE_SIZE` bigint NOT NULL DEFAULT 0,
- `FILE_VERSION` int(11) NOT NULL DEFAULT 0, -- used for update
- `A_STATUS` enum('WAITING','NORMAL','MONITOR','OFF_HARD','OFF_SOFT','DELETED','WARNING') NOT NULL DEFAULT 'WAITING',
- `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
- `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
- `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL,
- `A_RECORD_UPDATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
- `A_ADM_COMPANY` varchar(100) NOT NULL DEFAULT '',
- `A_CLASSIFIED` varchar(100) NOT NULL DEFAULT '',
- `A_USER_IP` bigint NOT NULL DEFAULT '0',
- PRIMARY KEY (`ID`),
- KEY `FILE_TYPE` (`FILE_TYPE`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
- ");
- DB::getPDO()->exec("
- CREATE TABLE IF NOT EXISTS `CRM_FILES__#VERSIONS` (
- `ID_FILE` int(11) NOT NULL,
- `FILE_HASH` varchar(255) NOT NULL, -- generated from ID by hash function - only for cache
- `FILE_LABEL` varchar(255) NOT NULL, -- original file name or system name
- `FILE_TYPE` varchar(32) NOT NULL DEFAULT '', -- $TRG_FILE -> config/.cnf--folders...
- `FILE_MIME_TYPE` varchar(64) NOT NULL DEFAULT '',
- `FILE_MTIME` datetime NOT NULL,
- `FILE_SIZE` bigint NOT NULL DEFAULT 0,
- `FILE_VERSION` int(11) NOT NULL DEFAULT 0, -- used for update
- `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
- `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
- `A_USER_IP` bigint NOT NULL DEFAULT '0',
- KEY `ID_FILE` (`ID_FILE`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
- ");
- DB::getPDO()->exec("
- CREATE TABLE IF NOT EXISTS `CRM_FILES__#DEV__#VERSIONS` (
- `ID_FILE` int(11) NOT NULL,
- `FILE_HASH` varchar(255) NOT NULL, -- generated from ID by hash function - only for cache
- `FILE_LABEL` varchar(255) NOT NULL, -- original file name or system name
- `FILE_TYPE` varchar(32) NOT NULL DEFAULT '', -- $TRG_FILE -> config/.cnf--folders...
- `FILE_MIME_TYPE` varchar(64) NOT NULL DEFAULT '',
- `FILE_MTIME` datetime NOT NULL,
- `FILE_SIZE` bigint NOT NULL DEFAULT 0,
- `FILE_VERSION` int(11) NOT NULL DEFAULT 0, -- used for update
- `A_RECORD_CREATE_DATE` datetime DEFAULT NULL,
- `A_RECORD_CREATE_AUTHOR` varchar(20) NOT NULL DEFAULT '',
- `A_USER_IP` bigint NOT NULL DEFAULT '0',
- KEY `ID_FILE` (`ID_FILE`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin2;
- ");
- {// TODO: only in cli mode - require root perms
- $devRootPath = '/tmp/test-upload-file-storage';
- if (!file_exists($devRootPath)) {
- @mkdir($devRootPath, $mode = 0777, $recursive = true);
- if (!file_exists($devRootPath)) throw new Exception("Cannot create FileStorage root path for dev");
- @chmod($devRootPath, $mode = 0777);
- @chown($devRootPath, $user = '_www');
- }
- $productionRootPath = '/Library/Server/Web/Data/p5-file-storage';
- if (!file_exists($productionRootPath)) {
- @mkdir($productionRootPath, $mode = 0775, $recursive = true);
- if (!file_exists($productionRootPath)) throw new Exception("Cannot create FileStorage root path");
- @chmod($productionRootPath, $mode = 0775);
- @chown($productionRootPath, $user = '_www');
- }
- }
- } catch (Exception $e) {
- UI::alert('danger', $e->getMessage());
- }
- }
- public static function isAllowedMimeType($mimeType) {
- // http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
- switch ($mimeType) {
- case 'image/png': return true;
- case 'application/atom+xml': return true;// atom
- case 'application/atomcat+xml': return true;// atomcat
- case 'application/atomsvc+xml': return true;// atomsvc
- case 'application/ccxml+xml': return true;// ccxml
- case 'application/cdmi-capability': return true;// cdmia
- case 'application/cdmi-container': return true;// cdmic
- case 'application/cdmi-domain': return true;// cdmid
- case 'application/cdmi-object': return true;// cdmio
- case 'application/cdmi-queue': return true;// cdmiq
- case 'application/cu-seeme': return true;// cu
- case 'application/davmount+xml': return true;// davmount
- case 'application/docbook+xml': return true;// dbk
- case 'application/dssc+der': return true;// dssc
- case 'application/dssc+xml': return true;// xdssc
- case 'application/ecmascript': return true;// ecma
- case 'application/emma+xml': return true;// emma
- case 'application/epub+zip': return true;// epub
- case 'application/exi': return true;// exi
- case 'application/font-tdpfr': return true;// pfr
- case 'application/font-woff': return true;// woff
- case 'application/gml+xml': return true;// gml
- case 'application/gpx+xml': return true;// gpx
- case 'application/gxf': return true;// gxf
- case 'application/hyperstudio': return true;// stk
- case 'application/inkml+xml': return true;// ink inkml
- case 'application/ipfix': return true;// ipfix
- case 'application/java-archive': return true;// jar
- case 'application/java-serialized-object': return true;// ser
- case 'application/java-vm': return true;// class
- case 'application/javascript': return true;// js
- case 'application/json': return true;// json
- case 'application/jsonml+json': return true;// jsonml
- case 'application/lost+xml': return true;// lostxml
- case 'application/mac-binhex40': return true;// hqx
- case 'application/mac-compactpro': return true;// cpt
- case 'application/mads+xml': return true;// mads
- case 'application/marc': return true;// mrc
- case 'application/marcxml+xml': return true;// mrcx
- case 'application/mathematica': return true;// ma nb mb
- case 'application/mathml+xml': return true;// mathml
- case 'application/mbox': return true;// mbox
- case 'application/mediaservercontrol+xml': return true;// mscml
- case 'application/metalink+xml': return true;// metalink
- case 'application/metalink4+xml': return true;// meta4
- case 'application/mets+xml': return true;// mets
- case 'application/mods+xml': return true;// mods
- case 'application/mp21': return true;// m21 mp21
- case 'application/mp4': return true;// mp4s
- case 'application/msword': return true;// doc dot
- case 'application/mxf': return true;// mxf
- case 'application/octet-stream': return true;// bin dms lrf mar so dist distz pkg bpk dump elc deploy
- case 'application/oda': return true;// oda
- case 'application/oebps-package+xml': return true;// opf
- case 'application/ogg': return true;// ogx
- case 'application/omdoc+xml': return true;// omdoc
- case 'application/onenote': return true;// onetoc2 onetmp onetoc onepkg
- case 'application/oxps': return true;// oxps
- case 'application/patch-ops-error+xml': return true;// xer
- case 'application/pdf': return true;// pdf
- case 'application/pgp-encrypted': return true;// pgp
- case 'application/pgp-signature': return true;// asc sig
- case 'application/pics-rules': return true;// prf
- case 'application/pkcs10': return true;// p10
- case 'application/pkcs7-mime': return true;// p7m p7c
- case 'application/pkcs7-signature': return true;// p7s
- case 'application/pkcs8': return true;// p8
- case 'application/pkix-attr-cert': return true;// ac
- case 'application/pkix-cert': return true;// cer
- case 'application/pkix-crl': return true;// crl
- case 'application/pkix-pkipath': return true;// pkipath
- case 'application/pkixcmp': return true;// pki
- case 'application/pls+xml': return true;// pls
- case 'application/postscript': return true;// ai eps ps
- case 'application/prs.cww': return true;// cww
- case 'application/pskc+xml': return true;// pskcxml
- case 'application/rdf+xml': return true;// rdf
- case 'application/reginfo+xml': return true;// rif
- case 'application/relax-ng-compact-syntax': return true;// rnc
- case 'application/resource-lists+xml': return true;// rl
- case 'application/resource-lists-diff+xml': return true;// rld
- case 'application/rls-services+xml': return true;// rs
- case 'application/rpki-ghostbusters': return true;// gbr
- case 'application/rpki-manifest': return true;// mft
- case 'application/rpki-roa': return true;// roa
- case 'application/rsd+xml': return true;// rsd
- case 'application/rss+xml': return true;// rss
- case 'application/rtf': return true;// rtf
- case 'application/sbml+xml': return true;// sbml
- case 'application/scvp-cv-request': return true;// scq
- case 'application/scvp-cv-response': return true;// scs
- case 'application/scvp-vp-request': return true;// spq
- case 'application/scvp-vp-response': return true;// spp
- case 'application/sdp': return true;// sdp
- case 'application/set-payment-initiation': return true;// setpay
- case 'application/set-registration-initiation': return true;// setreg
- case 'application/shf+xml': return true;// shf
- case 'application/smil+xml': return true;// smi smil
- case 'application/sparql-query': return true;// rq
- case 'application/sparql-results+xml': return true;// srx
- case 'application/srgs': return true;// gram
- case 'application/srgs+xml': return true;// grxml
- case 'application/sru+xml': return true;// sru
- case 'application/ssdl+xml': return true;// ssdl
- case 'application/ssml+xml': return true;// ssml
- case 'application/tei+xml': return true;// tei teicorpus
- case 'application/thraud+xml': return true;// tfi
- case 'application/timestamped-data': return true;// tsd
- case 'application/vnd.3gpp.pic-bw-large': return true;// plb
- case 'application/vnd.3gpp.pic-bw-small': return true;// psb
- case 'application/vnd.3gpp.pic-bw-var': return true;// pvb
- case 'application/vnd.3gpp2.tcap': return true;// tcap
- case 'application/vnd.3m.post-it-notes': return true;// pwn
- case 'application/vnd.accpac.simply.aso': return true;// aso
- case 'application/vnd.accpac.simply.imp': return true;// imp
- case 'application/vnd.acucobol': return true;// acu
- case 'application/vnd.acucorp': return true;// atc acutc
- case 'application/vnd.adobe.air-application-installer-package+zip': return true;// air
- case 'application/vnd.adobe.formscentral.fcdt': return true;// fcdt
- case 'application/vnd.adobe.fxp': return true;// fxp fxpl
- case 'application/vnd.adobe.xdp+xml': return true;// xdp
- case 'application/vnd.adobe.xfdf': return true;// xfdf
- case 'application/vnd.ahead.space': return true;// ahead
- case 'application/vnd.airzip.filesecure.azf': return true;// azf
- case 'application/vnd.airzip.filesecure.azs': return true;// azs
- case 'application/vnd.amazon.ebook': return true;// azw
- case 'application/vnd.americandynamics.acc': return true;// acc
- case 'application/vnd.amiga.ami': return true;// ami
- case 'application/vnd.android.package-archive': return true;// apk
- case 'application/vnd.anser-web-certificate-issue-initiation': return true;// cii
- case 'application/vnd.anser-web-funds-transfer-initiation': return true;// fti
- case 'application/vnd.antix.game-component': return true;// atx
- case 'application/vnd.apple.installer+xml': return true;// mpkg
- case 'application/vnd.apple.mpegurl': return true;// m3u8
- case 'application/vnd.aristanetworks.swi': return true;// swi
- case 'application/vnd.astraea-software.iota': return true;// iota
- case 'application/vnd.audiograph': return true;// aep
- case 'application/vnd.blueice.multipass': return true;// mpm
- case 'application/vnd.bmi': return true;// bmi
- case 'application/vnd.businessobjects': return true;// rep
- case 'application/vnd.chemdraw+xml': return true;// cdxml
- case 'application/vnd.chipnuts.karaoke-mmd': return true;// mmd
- case 'application/vnd.cinderella': return true;// cdy
- case 'application/vnd.claymore': return true;// cla
- case 'application/vnd.cloanto.rp9': return true;// rp9
- case 'application/vnd.clonk.c4group': return true;// c4g c4d c4f c4p c4u
- case 'application/vnd.cluetrust.cartomobile-config': return true;// c11amc
- case 'application/vnd.cluetrust.cartomobile-config-pkg': return true;// c11amz
- case 'application/vnd.commonspace': return true;// csp
- case 'application/vnd.contact.cmsg': return true;// cdbcmsg
- case 'application/vnd.cosmocaller': return true;// cmc
- case 'application/vnd.crick.clicker': return true;// clkx
- case 'application/vnd.crick.clicker.keyboard': return true;// clkk
- case 'application/vnd.crick.clicker.palette': return true;// clkp
- case 'application/vnd.crick.clicker.template': return true;// clkt
- case 'application/vnd.crick.clicker.wordbank': return true;// clkw
- case 'application/vnd.criticaltools.wbs+xml': return true;// wbs
- case 'application/vnd.ctc-posml': return true;// pml
- case 'application/vnd.cups-ppd': return true;// ppd
- case 'application/vnd.curl.car': return true;// car
- case 'application/vnd.curl.pcurl': return true;// pcurl
- case 'application/vnd.dart': return true;// dart
- case 'application/vnd.data-vision.rdz': return true;// rdz
- case 'application/vnd.dece.data': return true;// uvf uvvf uvd uvvd
- case 'application/vnd.dece.ttml+xml': return true;// uvt uvvt
- case 'application/vnd.dece.unspecified': return true;// uvx uvvx
- case 'application/vnd.dece.zip': return true;// uvz uvvz
- case 'application/vnd.denovo.fcselayout-link': return true;// fe_launch
- case 'application/vnd.dna': return true;// dna
- case 'application/vnd.dolby.mlp': return true;// mlp
- case 'application/vnd.dpgraph': return true;// dpg
- case 'application/vnd.dreamfactory': return true;// dfac
- case 'application/vnd.ds-keypoint': return true;// kpxx
- case 'application/vnd.dvb.ait': return true;// ait
- case 'application/vnd.dvb.service': return true;// svc
- case 'application/vnd.dynageo': return true;// geo
- case 'application/vnd.ecowin.chart': return true;// mag
- case 'application/vnd.enliven': return true;// nml
- case 'application/vnd.epson.esf': return true;// esf
- case 'application/vnd.epson.msf': return true;// msf
- case 'application/vnd.epson.quickanime': return true;// qam
- case 'application/vnd.epson.salt': return true;// slt
- case 'application/vnd.epson.ssf': return true;// ssf
- case 'application/vnd.eszigno3+xml es3': return true;// et3
- case 'application/vnd.ezpix-album': return true;// ez2
- case 'application/vnd.ezpix-package': return true;// ez3
- case 'application/vnd.fdf': return true;// fdf
- case 'application/vnd.fdsn.mseed': return true;// mseed
- case 'application/vnd.fdsn.seed': return true;// seed dataless
- case 'application/vnd.flographit': return true;// gph
- case 'application/vnd.fluxtime.clip': return true;// ftc
- case 'application/vnd.framemaker': return true;// fm frame maker book
- case 'application/vnd.frogans.fnc': return true;// fnc
- case 'application/vnd.frogans.ltf': return true;// ltf
- case 'application/vnd.fsc.weblaunch': return true;// fsc
- case 'application/vnd.fujitsu.oasys': return true;// oas
- case 'application/vnd.fujitsu.oasys2': return true;// oa2
- case 'application/vnd.fujitsu.oasys3': return true;// oa3
- case 'application/vnd.fujitsu.oasysgp': return true;// fg5
- case 'application/vnd.fujitsu.oasysprs': return true;// bh2
- case 'application/vnd.fujixerox.ddd': return true;// ddd
- case 'application/vnd.fujixerox.docuworks': return true;// xdw
- case 'application/vnd.fujixerox.docuworks.binder': return true;// xbd
- case 'application/vnd.fuzzysheet': return true;// fzs
- case 'application/vnd.genomatix.tuxedo': return true;// txd
- case 'application/vnd.geogebra.file': return true;// ggb
- case 'application/vnd.geogebra.tool': return true;// ggt
- case 'application/vnd.geometry-explorer': return true;// gex gre
- case 'application/vnd.geonext': return true;// gxt
- case 'application/vnd.geoplan': return true;// g2w
- case 'application/vnd.geospace': return true;// g3w
- case 'application/vnd.gmx': return true;// gmx
- case 'application/vnd.google-earth.kml+xml': return true;// kml
- case 'application/vnd.google-earth.kmz': return true;// kmz
- case 'application/vnd.grafeq': return true;// gqf gqs
- case 'application/vnd.groove-account': return true;// gac
- case 'application/vnd.groove-help': return true;// ghf
- case 'application/vnd.groove-identity-message': return true;// gim
- case 'application/vnd.groove-injector': return true;// grv
- case 'application/vnd.groove-tool-message': return true;// gtm
- case 'application/vnd.groove-tool-template': return true;// tpl
- case 'application/vnd.groove-vcard': return true;// vcg
- case 'application/vnd.hal+xml': return true;// hal
- case 'application/vnd.handheld-entertainment+xml': return true;// zmm
- case 'application/vnd.hbci': return true;// hbci
- case 'application/vnd.hhe.lesson-player': return true;// les
- case 'application/vnd.hp-hpgl': return true;// hpgl
- case 'application/vnd.hp-hpid': return true;// hpid
- case 'application/vnd.hp-hps': return true;// hps
- case 'application/vnd.hp-jlyt': return true;// jlt
- case 'application/vnd.hp-pcl': return true;// pcl
- case 'application/vnd.hp-pclxl': return true;// pclxl
- case 'application/vnd.hydrostatix.sof-data': return true;// sfd- hdstx
- case 'application/vnd.ibm.minipay': return true;// mpy
- case 'application/vnd.ibm.modcap': return true;// afp listafp list3820
- case 'application/vnd.ibm.rights-management': return true;// irm
- case 'application/vnd.ibm.secure-container': return true;// sc
- case 'application/vnd.iccprofile': return true;// icc icm
- case 'application/vnd.igloader': return true;// igl
- case 'application/vnd.immervision-ivp': return true;// ivp
- case 'application/vnd.immervision-ivu': return true;// ivu
- case 'application/vnd.insors.igm': return true;// igm
- case 'application/vnd.intercon.formnet': return true;// xpw xpx
- case 'application/vnd.intergeo': return true;// i2g
- case 'application/vnd.intu.qbo': return true;// qbo
- case 'application/vnd.intu.qfx': return true;// qfx
- case 'application/vnd.ipunplugged.rcprofile': return true;// rcprofile
- case 'application/vnd.irepository.package+xml': return true;// irp
- case 'application/vnd.is-xpr': return true;// xpr
- case 'application/vnd.isac.fcs': return true;// fcs
- case 'application/vnd.jam': return true;// jam
- case 'application/vnd.jcp.javame.midlet-rms': return true;// rms
- case 'application/vnd.jisp': return true;// jisp
- case 'application/vnd.joost.joda-archive': return true;// joda
- case 'application/vnd.kahootz': return true;// ktz ktr
- case 'application/vnd.kde.karbon': return true;// karbon
- case 'application/vnd.kde.kchart': return true;// chrt
- case 'application/vnd.kde.kformula': return true;// kfo
- case 'application/vnd.kde.kivio': return true;// flw
- case 'application/vnd.kde.kontour': return true;// kon
- case 'application/vnd.kde.kpresenter': return true;// kpr kpt
- case 'application/vnd.kde.kspread': return true;// ksp
- case 'application/vnd.kde.kword': return true;// kwd kwt
- case 'application/vnd.kenameaapp': return true;// htke
- case 'application/vnd.kidspiration': return true;// kia
- case 'application/vnd.kinar': return true;// kne knp
- case 'application/vnd.koan': return true;// skp skd skt skm
- case 'application/vnd.kodak-descriptor': return true;// sse
- case 'application/vnd.las.las+xml': return true;// lasxml
- case 'application/vnd.llamagraphics.life-balance.desktop': return true;// lbd
- case 'application/vnd.llamagraphics.life-balance.exchange+xml': return true;// lbe
- case 'application/vnd.lotus-1-2-3': return true;// 123
- case 'application/vnd.lotus-approach': return true;// apr
- case 'application/vnd.lotus-freelance': return true;// pre
- case 'application/vnd.lotus-notes': return true;// nsf
- case 'application/vnd.lotus-organizer': return true;// org
- case 'application/vnd.lotus-screencam': return true;// scm
- case 'application/vnd.lotus-wordpro': return true;// lwp
- case 'application/vnd.macports.portpkg': return true;// portpkg
- case 'application/vnd.mcd': return true;// mcd
- case 'application/vnd.medcalcdata': return true;// mc1
- case 'application/vnd.mediastation.cdkey': return true;// cdkey
- case 'application/vnd.mfer': return true;// mwf
- case 'application/vnd.mfmp': return true;// mfm
- case 'application/vnd.micrografx.flo': return true;// flo
- case 'application/vnd.micrografx.igx': return true;// igx
- case 'application/vnd.mif': return true;// mif
- case 'application/vnd.mobius.daf': return true;// daf
- case 'application/vnd.mobius.dis': return true;// dis
- case 'application/vnd.mobius.mbk': return true;// mbk
- case 'application/vnd.mobius.mqy': return true;// mqy
- case 'application/vnd.mobius.msl': return true;// msl
- case 'application/vnd.mobius.plc': return true;// plc
- case 'application/vnd.mobius.txf': return true;// txf
- case 'application/vnd.mophun.application': return true;// mpn
- case 'application/vnd.mophun.certificate': return true;// mpc
- case 'application/vnd.mozilla.xul+xml': return true;// xul
- case 'application/vnd.ms-artgalry': return true;// cil
- case 'application/vnd.ms-cab-compressed': return true;// cab
- case 'application/vnd.ms-excel': return true;// xls xlm xla xlc xlt xlw
- case 'application/vnd.ms-excel.addin.macroenabled.12': return true;// xlam
- case 'application/vnd.ms-excel.sheet.binary.macroenabled.12': return true;// xlsb
- case 'application/vnd.ms-excel.sheet.macroenabled.12': return true;// xlsm
- case 'application/vnd.ms-excel.template.macroenabled.12': return true;// xltm
- case 'application/vnd.ms-fontobject': return true;// eot
- case 'application/vnd.ms-htmlhelp': return true;// chm
- case 'application/vnd.ms-ims': return true;// ims
- case 'application/vnd.ms-lrm': return true;// lrm
- case 'application/vnd.ms-office': return true;// theme thmx
- case 'application/vnd.ms-pki.seccat': return true;// cat
- case 'application/vnd.ms-pki.stl': return true;// stl
- case 'application/vnd.ms-powerpoint': return true;// ppt pps pot
- case 'application/vnd.ms-powerpoint.addin.macroenabled.12': return true;// ppam
- case 'application/vnd.ms-powerpoint.presentation.macroenabled.12': return true;// pptm
- case 'application/vnd.ms-powerpoint.slide.macroenabled.12': return true;// sldm
- case 'application/vnd.ms-powerpoint.slideshow.macroenabled.12': return true;// ppsm
- case 'application/vnd.ms-powerpoint.template.macroenabled.12': return true;// potm
- case 'application/vnd.ms-project': return true;// mpp mpt
- case 'application/vnd.ms-word.document.macroenabled.12': return true;// docm
- case 'application/vnd.ms-word.template.macroenabled.12': return true;// dotm
- case 'application/vnd.ms-works': return true;// wps wks wcm wdb
- case 'application/vnd.ms-wpl': return true;// wpl
- case 'application/vnd.ms-xpsdocument': return true;// xps
- case 'application/vnd.mseq': return true;// mseq
- case 'application/vnd.musician': return true;// mus
- case 'application/vnd.muvee.style': return true;// msty
- case 'application/vnd.mynfc': return true;// taglet
- case 'application/vnd.neurolanguage.nlu': return true;// nlu
- case 'application/vnd.nitf': return true;// ntf nitf
- case 'application/vnd.noblenet-directory': return true;// nnd
- case 'application/vnd.noblenet-sealer': return true;// nns
- case 'application/vnd.noblenet-web': return true;// nnw
- case 'application/vnd.nokia.n-gage.data': return true;// ngdat
- case 'application/vnd.nokia.n-gage.symbian.install': return true;// n- gage
- case 'application/vnd.nokia.radio-preset': return true;// rpst
- case 'application/vnd.nokia.radio-presets': return true;// rpss
- case 'application/vnd.novadigm.edm': return true;// edm
- case 'application/vnd.novadigm.edx': return true;// edx
- case 'application/vnd.novadigm.ext': return true;// ext
- case 'application/vnd.oasis.opendocument.chart': return true;// odc
- case 'application/vnd.oasis.opendocument.chart-template': return true;// otc
- case 'application/vnd.oasis.opendocument.database': return true;// odb
- case 'application/vnd.oasis.opendocument.formula': return true;// odf
- case 'application/vnd.oasis.opendocument.formula-template': return true;// odft
- case 'application/vnd.oasis.opendocument.graphics': return true;// odg
- case 'application/vnd.oasis.opendocument.graphics-template': return true;// otg
- case 'application/vnd.oasis.opendocument.image': return true;// odi
- case 'application/vnd.oasis.opendocument.image-template': return true;// oti
- case 'application/vnd.oasis.opendocument.presentation': return true;// odp
- case 'application/vnd.oasis.opendocument.presentation-template': return true;// otp
- case 'application/vnd.oasis.opendocument.spreadsheet': return true;// ods
- case 'application/vnd.oasis.opendocument.spreadsheet-template': return true;// ots
- case 'application/vnd.oasis.opendocument.text': return true;// odt
- case 'application/vnd.oasis.opendocument.text-master': return true;// odm
- case 'application/vnd.oasis.opendocument.text-template': return true;// ott
- case 'application/vnd.oasis.opendocument.text-web': return true;// oth
- case 'application/vnd.olpc-sugar': return true;// xo
- case 'application/vnd.oma.dd2+xml': return true;// dd2
- case 'application/vnd.openofficeorg.extension': return true;// oxt
- case 'application/vnd.openxmlformats-officedocument.presentationml.presentation': return true;// pptx
- case 'application/vnd.openxmlformats-officedocument.presentationml.slide': return true;// sldx
- case 'application/vnd.openxmlformats-officedocument.presentationml.slideshow': return true;// ppsx
- case 'application/vnd.openxmlformats-officedocument.presentationml.template': return true;// potx
- case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': return true;// xlsx
- case 'application/vnd.openxmlformats-officedocument.spreadsheetml.template': return true;// xltx
- case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': return true;// docx
- case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template': return true;// dotx
- case 'application/vnd.osgeo.mapguide.package': return true;// mgp
- case 'application/vnd.osgi.dp': return true;// dp
- case 'application/vnd.osgi.subsystem': return true;// esa
- case 'application/vnd.palm': return true;// pdb pqa oprc
- case 'application/vnd.pawaafile': return true;// paw
- case 'application/vnd.pg.format': return true;// str
- case 'application/vnd.pg.osasli': return true;// ei6
- case 'application/vnd.picsel': return true;// efif
- case 'application/vnd.pmi.widget': return true;// wg
- case 'application/vnd.pocketlearn': return true;// plf
- case 'application/vnd.powerbuilder6': return true;// pbd
- case 'application/vnd.previewsystems.box': return true;// box
- case 'application/vnd.proteus.magazine': return true;// mgz
- case 'application/vnd.publishare-delta-tree': return true;// qps
- case 'application/vnd.pvi.ptid1': return true;// ptid
- case 'application/vnd.quark.quarkxpress': return true;// qxd qxt qwd qwt qxl qxb
- case 'application/vnd.realvnc.bed': return true;// bed
- case 'application/vnd.recordare.musicxml': return true;// mxl
- case 'application/vnd.recordare.musicxml+xml': return true;// musicxml
- case 'application/vnd.rig.cryptonote': return true;// cryptonote
- case 'application/vnd.rim.cod': return true;// cod
- case 'application/vnd.rn-realmedia': return true;// rm
- case 'application/vnd.rn-realmedia-vbr': return true;// rmvb
- case 'application/vnd.route66.link66+xml': return true;// link66
- case 'application/vnd.sailingtracker.track': return true;// st
- case 'application/vnd.seemail': return true;// see
- case 'application/vnd.sema': return true;// sema
- case 'application/vnd.semd': return true;// semd
- case 'application/vnd.semf': return true;// semf
- case 'application/vnd.shana.informed.formdata': return true;// ifm
- case 'application/vnd.shana.informed.formtemplate': return true;// itp
- case 'application/vnd.shana.informed.interchange': return true;// iif
- case 'application/vnd.shana.informed.package': return true;// ipk
- case 'application/vnd.simtech-mindmapper': return true;// twd twds
- case 'application/vnd.smaf': return true;// mmf
- case 'application/vnd.smart.teacher': return true;// teacher
- case 'application/vnd.solent.sdkm+xml': return true;// sdkm sdkd
- case 'application/vnd.spotfire.dxp': return true;// dxp
- case 'application/vnd.spotfire.sfs': return true;// sfs
- case 'application/vnd.stardivision.calc': return true;// sdc
- case 'application/vnd.stardivision.draw': return true;// sda
- case 'application/vnd.stardivision.impress': return true;// sdd
- case 'application/vnd.stardivision.math': return true;// smf
- case 'application/vnd.stardivision.writer': return true;// sdw vor
- case 'application/vnd.stardivision.writer-global': return true;// sgl
- case 'application/vnd.stepmania.package': return true;// smzip
- case 'application/vnd.stepmania.stepchart': return true;// sm
- case 'application/vnd.sun.xml.calc': return true;// sxc
- case 'application/vnd.sun.xml.calc.template': return true;// stc
- case 'application/vnd.sun.xml.draw': return true;// sxd
- case 'application/vnd.sun.xml.draw.template': return true;// std
- case 'application/vnd.sun.xml.impress': return true;// sxi
- case 'application/vnd.sun.xml.impress.template': return true;// sti
- case 'application/vnd.sun.xml.math': return true;// sxm
- case 'application/vnd.sun.xml.writer': return true;// sxw
- case 'application/vnd.sun.xml.writer.global': return true;// sxg
- case 'application/vnd.sun.xml.writer.template': return true;// stw
- case 'application/vnd.sus-calendar': return true;// sus susp
- case 'application/vnd.svd': return true;// svd
- case 'application/vnd.symbian.install sis': return true;// sisx
- case 'application/vnd.syncml+xml': return true;// xsm
- case 'application/vnd.syncml.dm+wbxml': return true;// bdm
- case 'application/vnd.syncml.dm+xml': return true;// xdm
- case 'application/vnd.tao.intent-module-archive': return true;// tao
- case 'application/vnd.tcpdump.pcap': return true;// pcap cap dmp
- case 'application/vnd.tmobile-livetv': return true;// tmo
- case 'application/vnd.trid.tpt': return true;// tpt
- case 'application/vnd.triscape.mxs': return true;// mxs
- case 'application/vnd.trueapp': return true;// tra
- case 'application/vnd.ufdl': return true;// ufd ufdl
- case 'application/vnd.uiq.theme': return true;// utz
- case 'application/vnd.umajin': return true;// umj
- case 'application/vnd.unity': return true;// unityweb
- case 'application/vnd.uoml+xml': return true;// uoml
- case 'application/vnd.vcx': return true;// vcx
- case 'application/vnd.visio': return true;// vsd vst vss vsw
- case 'application/vnd.visionary': return true;// vis
- case 'application/vnd.vsf': return true;// vsf
- case 'application/vnd.wap.wbxml': return true;// wbxml
- case 'application/vnd.wap.wmlc': return true;// wmlc
- case 'application/vnd.wap.wmlscriptc': return true;// wmlsc
- case 'application/vnd.webturbo': return true;// wtb
- case 'application/vnd.wolfram.player': return true;// nbp
- case 'application/vnd.wordperfect': return true;// wpd
- case 'application/vnd.wqd': return true;// wqd
- case 'application/vnd.wt.stf': return true;// stf
- case 'application/vnd.xara': return true;// xar
- case 'application/vnd.xfdl': return true;// xfdl
- case 'application/vnd.yamaha.hv-dic': return true;// hvd
- case 'application/vnd.yamaha.hv-script': return true;// hvs
- case 'application/vnd.yamaha.hv-voice': return true;// hvp
- case 'application/vnd.yamaha.openscoreformat': return true;// osf
- case 'application/vnd.yamaha.openscoreformat.osfpvg+xml': return true;// osfpvg
- case 'application/vnd.yamaha.smaf-audio': return true;// saf
- case 'application/vnd.yamaha.smaf-phrase': return true;// spf
- case 'application/vnd.yellowriver-custom-menu': return true;// cmp
- case 'application/vnd.zul': return true;// zir zirz
- case 'application/vnd.zzazz.deck+xml': return true;// zaz
- case 'application/voicexml+xml': return true;// vxml
- case 'application/widget': return true;// wgt
- case 'application/winhlp': return true;// hlp
- case 'application/wsdl+xml': return true;// wsdl
- case 'application/wspolicy+xml': return true;// wspolicy
- case 'application/x-7z-compressed': return true;// 7z
- case 'application/x-abiword': return true;// abw
- case 'application/x-ace-compressed': return true;// ace
- case 'application/x-apple-diskimage': return true;// dmg
- case 'application/x-authorware-bin': return true;// aab x32 u32 vox
- case 'application/x-authorware-map': return true;// aam
- case 'application/x-authorware-seg': return true;// aas
- case 'application/x-archive': return true;// ADMIN_USERS//5027.Pawel_Kamola/projekty/grafy_projekt_python/grafy/numpy/core/lib/libnpymath.a
- case 'application/x-empty': return false;// empty files
- case 'application/x-bcpio': return true;// bcpio
- case 'application/x-bittorrent': return true;// torrent
- case 'application/x-blorb': return true;// blb blorb
- case 'application/x-bzip': return true;// bz
- case 'application/x-bzip2': return true;// bz2 boz
- case 'application/x-cbr': return true;// cbr cba cbt cbz cb7
- case 'application/x-cdlink': return true;// vcd
- case 'application/x-cfs-compressed': return true;// cfs
- case 'application/x-chat': return true;// chat
- case 'application/x-chess-pgn': return true;// pgn
- case 'application/x-conference': return true;// nsc
- case 'application/x-cpio': return true;// cpio
- case 'application/x-csh': return true;// csh
- case 'application/x-debian-package': return true;// deb udeb
- case 'application/x-dgc-compressed': return true;// dgc
- case 'application/x-director': return true;// dir dcr dxr cst cct cxt w3d fgd swa
- case 'application/x-doom': return true;// wad
- case 'application/x-dtbncx+xml': return true;// ncx
- case 'application/x-dtbook+xml': return true;// dtb
- case 'application/x-dtbresource+xml': return true;// res
- case 'application/x-dvi': return true;// dvi
- case 'application/x-envoy': return true;// evy
- case 'application/x-eva': return true;// eva
- case 'application/x-font-bdf': return true;// bdf
- case 'application/x-font-ghostscript': return true;// gsf
- case 'application/x-font-linux-psf': return true;// psf
- case 'application/x-font-otf': return true;// otf
- case 'application/x-font-pcf': return true;// pcf
- case 'application/x-font-snf': return true;// snf
- case 'application/x-font-ttf': return true;// ttc ttf
- case 'application/x-font-type1': return true;// afm pfa pfb pfm
- case 'application/x-freearc': return true;// arc
- case 'application/x-futuresplash': return true;// spl
- case 'application/x-executable': return true;//
- case 'application/x-gca-compressed': return true;// gca
- case 'application/x-glulx': return true;// ulx
- case 'application/x-gnumeric': return true;// gnumeric
- case 'application/x-gramps-xml': return true;// gramps
- case 'application/x-gtar': return true;// gtar
- case 'application/x-gzip': return true;// gz gzip
- case 'application/x-hdf': return true;// hdf
- case 'application/x-install-instructions': return true;// install
- case 'application/x-iso9660-image': return true;// iso
- case 'application/x-java-jnlp-file': return true;// jnlp
- case 'application/x-latex': return true;// latex
- case 'application/x-lzh-compressed': return true;// lha lzh
- case 'application/x-mie': return true;// mie
- case 'application/x-mobipocket-ebook': return true;// mobi prc
- case 'application/x-ms-application': return true;// application
- case 'application/x-ms-shortcut': return true;// lnk
- case 'application/x-ms-wmd': return true;// wmd
- case 'application/x-ms-wmz': return true;// wmz
- case 'application/x-ms-xbap': return true;// xbap
- case 'application/x-msaccess': return true;// mdb
- case 'application/x-msbinder': return true;// obd
- case 'application/x-mscardfile': return true;// crd
- case 'application/x-msclip': return true;// clp
- case 'application/x-msdownload': return true;// msi exe dll com bat
- case 'application/x-msmediaview': return true;// m14 mvb m13
- case 'application/x-msmetafile': return true;// emz wmf wmz emf
- case 'application/x-msmoney': return true;// mny
- case 'application/x-mspublisher': return true;// pub
- case 'application/x-msschedule': return true;// scd
- case 'application/x-msterminal': return true;// trm
- case 'application/x-mswrite': return true;// wri
- case 'application/x-netcdf': return true;// cdf nc
- case 'application/x-nzb': return true;// nzb
- case 'application/x-pkcs12': return true;// pfx p12
- case 'application/x-pkcs7-certificates': return true;// spc p7b
- case 'application/x-pkcs7-certreqresp': return true;// p7r
- case 'application/x-rar': return true;// rar
- case 'application/x-rar-compressed': return true;// rar
- case 'application/x-research-info-systems': return true;// ris
- case 'application/x-sh': return true;// sh
- case 'application/x-shar': return true;// shar
- case 'application/x-shockwave-flash': return true;// swf
- case 'application/x-silverlight-app': return true;// xap
- case 'application/x-sql': return true;// sql
- case 'application/x-stuffit': return true;// sit
- case 'application/x-stuffitx': return true;// sitx
- case 'application/x-subrip': return true;// srt
- case 'application/x-sv4cpio': return true;// sv4cpio
- case 'application/x-sv4crc': return true;// sv4crc
- case 'application/x-t3vm-image': return true;// t3
- case 'application/x-tads': return true;// gam
- case 'application/x-tar': return true;// tar
- case 'application/x-tcl': return true;// tcl
- case 'application/x-tex': return true;// tex
- case 'application/x-tex-tfm': return true;// tfm
- case 'application/x-texinfo': return true;// texi texinfo
- case 'application/x-tgif': return true;// obj
- case 'application/x-ustar': return true;// ustar
- case 'application/x-wais-source': return true;// src
- case 'application/x-x509-ca-cert': return true;// crt der
- case 'application/x-xfig': return true;// fig
- case 'application/x-xliff+xml': return true;// xlf
- case 'application/x-xpinstall': return true;// xpi
- case 'application/x-xz': return true;// xz
- case 'application/x-zmachine': return true;// z8 z1 z2 z3 z4 z5 z6 z7
- case 'application/xaml+xml': return true;// xaml
- case 'application/xcap-diff+xml': return true;// xdf
- case 'application/xenc+xml': return true;// xenc
- case 'application/xhtml+xml': return true;// xht xhtml
- case 'application/xml': return true;// xsl xml
- case 'application/xml-dtd': return true;// dtd
- case 'application/xop+xml': return true;// xop
- case 'application/xproc+xml': return true;// xpl
- case 'application/xslt+xml': return true;// xslt
- case 'application/xspf+xml': return true;// xspf
- case 'application/xv+xml': return true;// xvm mxml xhvml xvml
- case 'application/yang': return true;// yang
- case 'application/yin+xml': return true;// yin
- case 'application/zip': return true;// zip
- case 'audio/adpcm': return true;// adp
- case 'audio/basic': return true;// snd au
- case 'audio/midi': return true;// rmi mid midi kar
- case 'audio/mp4': return true;// mp4a m4a
- case 'audio/mpeg': return true;// m3a mpga mp2 mp2a mp3 m2a
- case 'audio/ogg': return true;// spx oga ogg
- case 'audio/s3m': return true;// s3m
- case 'audio/silk': return true;// sil
- case 'audio/vnd.dece.audio': return true;// uvva uva
- case 'audio/vnd.digital-winds': return true;// eol
- case 'audio/vnd.dra': return true;// dra
- case 'audio/vnd.dts': return true;// dts
- case 'audio/vnd.dts.hd': return true;// dtshd
- case 'audio/vnd.lucent.voice': return true;// lvp
- case 'audio/vnd.ms-playready.media.pya': return true;// pya
- case 'audio/vnd.nuera.ecelp4800': return true;// ecelp4800
- case 'audio/vnd.nuera.ecelp7470': return true;// ecelp7470
- case 'audio/vnd.nuera.ecelp9600': return true;// ecelp9600
- case 'audio/vnd.rip': return true;// rip
- case 'audio/webm': return true;// weba
- case 'audio/x-aac': return true;// aac
- case 'audio/x-aiff': return true;// aifc aif aiff
- case 'audio/x-caf': return true;// caf
- case 'audio/x-flac': return true;// flac
- case 'audio/x-matroska': return true;// mka
- case 'audio/x-mpegurl': return true;// m3u
- case 'audio/x-ms-wax': return true;// wax
- case 'audio/x-ms-wma': return true;// wma
- case 'audio/x-pn-realaudio': return true;// ra ram
- case 'audio/x-pn-realaudio-plugin': return true;// rmp
- case 'audio/x-wav': return true;// wav
- case 'audio/xm': return true;// xm
- case 'chemical/x-cdx': return true;// cdx
- case 'chemical/x-cif': return true;// cif
- case 'chemical/x-cmdf': return true;// cmdf
- case 'chemical/x-cml': return true;// cml
- case 'chemical/x-csml': return true;// csml
- case 'chemical/x-xyz': return true;// xyz
- case 'image/bmp': return true;// bmp
- case 'image/cgm': return true;// cgm
- case 'image/g3fax': return true;// g3
- case 'image/gif': return true;// gif
- case 'image/ief': return true;// ief
- case 'image/jpeg': return true;// jpe jpeg jpg
- case 'image/ktx': return true;// ktx
- case 'image/png': return true;// png
- case 'image/prs.btif': return true;// btif
- case 'image/sgi': return true;// sgi
- case 'image/svg+xml': return true;// svgz svg
- case 'image/tiff': return true;// tif tiff
- case 'image/vnd.adobe.photoshop': return true;// psd
- case 'image/vnd.dece.graphic': return true;// uvvg uvi uvvi uvg
- case 'image/vnd.djvu': return true;// djv djvu
- case 'image/vnd.dvb.subtitle': return true;// sub
- case 'image/vnd.dwg': return true;// dwg
- case 'image/vnd.dxf': return true;// dxf
- case 'image/vnd.fastbidsheet': return true;// fbs
- case 'image/vnd.fpx': return true;// fpx
- case 'image/vnd.fst': return true;// fst
- case 'image/vnd.fujixerox.edmics-mmr': return true;// mmr
- case 'image/vnd.fujixerox.edmics-rlc': return true;// rlc
- case 'image/vnd.ms-modi': return true;// mdi
- case 'image/vnd.ms-photo': return true;// wdp
- case 'image/vnd.net-fpx': return true;// npx
- case 'image/vnd.wap.wbmp': return true;// wbmp
- case 'image/vnd.xiff': return true;// xif
- case 'image/webp': return true;// webp
- case 'image/x-3ds': return true;// 3ds
- case 'image/x-cmu-raster': return true;// ras
- case 'image/x-cmx': return true;// cmx
- case 'image/x-freehand': return true;// fh7 fh fhc fh4 fh5
- case 'image/x-ico': return true;// ico
- case 'image/x-icon': return true;// ico
- case 'image/x-mrsid-image': return true;// sid
- case 'image/x-ms-bmp': return true;// bmp
- case 'image/x-pcx': return true;// pcx
- case 'image/x-pict': return true;// pct pic
- case 'image/x-portable-anymap': return true;// pnm
- case 'image/x-portable-bitmap': return true;// pbm
- case 'image/x-portable-graymap': return true;// pgm
- case 'image/x-portable-greymap': return true;// pgm
- case 'image/x-portable-pixmap': return true;// ppm
- case 'image/x-rgb': return true;// rgb
- case 'image/x-tga': return true;// tga
- case 'image/x-xbitmap': return true;// xbm
- case 'image/x-xpixmap': return true;// xpm
- case 'image/x-xwindowdump': return true;// xwd
- case 'inode/x-empty': return false;// empty file
- case 'message/rfc822': return true;// mime eml
- case 'model/iges': return true;// iges igs
- case 'model/mesh': return true;// silo msh mesh
- case 'model/vnd.collada+xml': return true;// dae
- case 'model/vnd.dwf': return true;// dwf
- case 'model/vnd.gdl': return true;// gdl
- case 'model/vnd.gtw': return true;// gtw
- case 'model/vnd.mts': return true;// mts
- case 'model/vnd.vtu': return true;// vtu
- case 'model/vrml': return true;// vrml wrl
- case 'model/x3d+binary': return true;// x3dbz x3db
- case 'model/x3d+vrml': return true;// x3dvz x3dv
- case 'model/x3d+xml': return true;// x3dz x3d
- case 'text/cache-manifest': return true;// appcache
- case 'text/calendar': return true;// ifb ics
- case 'text/css': return true;// css
- case 'text/csv': return true;// csv
- case 'text/html': return true;// htm html
- case 'text/n3': return true;// n3
- case 'text/plain': return true;// in txt text conf def list log
- case 'text/prs.lines.tag': return true;// dsc
- case 'text/rtf': return true;// rtf
- case 'text/richtext': return true;// rtx
- case 'text/sgml': return true;// sgm sgml
- case 'text/tab-separated-values': return true;// tsv
- case 'text/troff': return true;// ms t tr roff man me
- case 'text/turtle': return true;// ttl
- case 'text/uri-list': return true;// urls uri uris
- case 'text/vcard': return true;// vcard
- case 'text/vnd.curl': return true;// curl
- case 'text/vnd.curl.dcurl': return true;// dcurl
- case 'text/vnd.curl.mcurl': return true;// mcurl
- case 'text/vnd.curl.scurl': return true;// scurl
- case 'text/vnd.dvb.subtitle': return true;// sub
- case 'text/vnd.fly': return true;// fly
- case 'text/vnd.fmi.flexstor': return true;// flx
- case 'text/vnd.graphviz': return true;// gv
- case 'text/vnd.in3d.3dml': return true;// 3dml
- case 'text/vnd.in3d.spot': return true;// spot
- case 'text/vnd.sun.j2me.app-descriptor': return true;// jad
- case 'text/vnd.wap.wml': return true;// wml
- case 'text/vnd.wap.wmlscript': return true;// wmls
- case 'text/x-asm': return true;// s asm
- case 'text/x-c': return true;// c cc cxx cpp h hh dic
- case 'text/x-c++': return true;// c++
- case 'text/x-fortran': return true;// f for f77 f90
- case 'text/x-java': return true;// java
- case 'text/x-java-source': return true;// java
- case 'text/x-makefile': return true;// Makefile
- case 'text/x-nfo': return true;// nfo
- case 'text/x-opml': return true;// opml
- case 'text/x-pascal': return true;// p pas
- case 'text/x-php': return true;// php
- case 'text/x-python': return true;// py
- case 'text/x-setext': return true;// etx
- case 'text/x-sfv': return true;// sfv
- case 'text/x-shellscript': return true;// ...
- case 'text/x-uuencode': return true;// uu
- case 'text/x-vcalendar': return true;// vcs
- case 'text/x-vcard': return true;// vcf
- case 'video/3gpp': return true;// 3gp
- case 'video/3gpp2': return true;// 3g2
- case 'video/h261': return true;// h261
- case 'video/h263': return true;// h263
- case 'video/h264': return true;// h264
- case 'video/jpeg': return true;// jpgv
- case 'video/jpm': return true;// jpm jpgm
- case 'video/mj2': return true;// mjp2 mj2
- case 'video/mp4': return true;// mpg4 mp4 mp4v
- case 'video/mpeg': return true;// m2v mpeg mpg mpe m1v
- case 'video/ogg': return true;// ogv
- case 'video/quicktime': return true;// mov qt
- case 'video/vnd.dece.hd': return true;// uvvh uvh
- case 'video/vnd.dece.mobile': return true;// uvvm uvm
- case 'video/vnd.dece.pd': return true;// uvvp uvp
- case 'video/vnd.dece.sd': return true;// uvvs uvs
- case 'video/vnd.dece.video': return true;// uvvv uvv
- case 'video/vnd.dvb.file': return true;// dvb
- case 'video/vnd.fvt': return true;// fvt
- case 'video/vnd.mpegurl': return true;// m4u mxu
- case 'video/vnd.ms-playready.media.pyv': return true;// pyv
- case 'video/vnd.uvvu.mp4': return true;// uvvu uvu
- case 'video/vnd.vivo': return true;// viv
- case 'video/webm': return true;// webm
- case 'video/x-f4v': return true;// f4v
- case 'video/x-fli': return true;// fli
- case 'video/x-flv': return true;// flv
- case 'video/x-m4v': return true;// m4v
- case 'video/x-matroska': return true;// mks mkv mk3d
- case 'video/x-mng': return true;// mng
- case 'video/x-ms-asf': return true;// asx asf
- case 'video/x-ms-vob': return true;// vob
- case 'video/x-ms-wm': return true;// wm
- case 'video/x-ms-wmv': return true;// wmv
- case 'video/x-ms-wmx': return true;// wmx
- case 'video/x-ms-wvx': return true;// wvx
- case 'video/x-msvideo': return true;// avi
- case 'video/x-sgi-movie': return true;// movie
- case 'video/x-smv': return true;// smv
- case 'x-conference/x-cooltalk': return true;// ice
- }
- return false;
- }
- public static function getMimeType($file) {
- if (!is_string($file)) return false;
- $mimeTypes = [
- 'txt' => 'text/plain',
- 'htm' => 'text/html',
- 'html' => 'text/html',
- 'php' => 'text/html',
- 'css' => 'text/css',
- 'js' => 'application/javascript',
- 'json' => 'application/json',
- 'xml' => 'application/xml',
- 'swf' => 'application/x-shockwave-flash',
- 'flv' => 'video/x-flv',
- 'png' => 'image/png',
- 'jpe' => 'image/jpeg',
- 'jpeg' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'gif' => 'image/gif',
- 'bmp' => 'image/bmp',
- 'ico' => 'image/vnd.microsoft.icon',
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'svg' => 'image/svg+xml',
- 'svgz' => 'image/svg+xml',
- 'zip' => 'application/zip',
- 'rar' => 'application/x-rar-compressed',
- 'exe' => 'application/x-msdownload',
- 'msi' => 'application/x-msdownload',
- 'cab' => 'application/vnd.ms-cab-compressed',
- 'mp3' => 'audio/mpeg',
- 'qt' => 'video/quicktime',
- 'mov' => 'video/quicktime',
- 'pdf' => 'application/pdf',
- 'psd' => 'image/vnd.adobe.photoshop',
- 'ai' => 'application/postscript',
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'doc' => 'application/msword',
- 'rtf' => 'application/rtf',
- 'xls' => 'application/vnd.ms-excel',
- 'ppt' => 'application/vnd.ms-powerpoint',
- 'odt' => 'application/vnd.oasis.opendocument.text',
- 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
- ];
- $ext = pathinfo($file)['extension'];
- if (isset($mimeTypes[$ext])) return $mimeTypes[$ext];
- if (!is_file($file)) return false;
- if (!is_readable($file)) return false;
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
- $mimeType = finfo_file($finfo, $file);
- finfo_close($finfo);
- return $mimeType;
- }
- }
|