summaryrefslogtreecommitdiffstats
path: root/lib/filestorage.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2011-07-17 15:22:04 +0200
committerRobin Appelman <icewind1991@gmail.com>2011-07-17 17:41:46 +0200
commit6935f036a5faa75383c18b21a1f7710b6d20c38c (patch)
treea703095a21400d4908ac4ba296ec95c26c64fd2b /lib/filestorage.php
parentf09f2d3290542f476de0276f1c2587ce9cd6a49f (diff)
downloadnextcloud-server-6935f036a5faa75383c18b21a1f7710b6d20c38c.tar.gz
nextcloud-server-6935f036a5faa75383c18b21a1f7710b6d20c38c.zip
move list of mimetypes by extention to a seperate file.
Diffstat (limited to 'lib/filestorage.php')
-rw-r--r--lib/filestorage.php70
1 files changed, 7 insertions, 63 deletions
diff --git a/lib/filestorage.php b/lib/filestorage.php
index 819ad2e60b3..c2614dc5dcf 100644
--- a/lib/filestorage.php
+++ b/lib/filestorage.php
@@ -65,6 +65,7 @@ OC_FILESYSTEM::registerStorageType('local','OC_FILESTORAGE_LOCAL',array('datadir
*/
class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
private $datadir;
+ private static $mimetypes=null;
public function __construct($arguments){
$this->datadir=$arguments['datadir'];
if(substr($this->datadir,-1)!=='/'){
@@ -209,71 +210,14 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
$mime_type=substr($reply,0,strrpos($reply,' '));
}
if (empty($mime_type)) {
- // Fallback solution: try to guess the type by the file extension
- // TODO: add more ...
- switch (strtolower(strrchr(basename($fspath), "."))) {
- case '.css':
- $mime_type = 'text/css';
- break;
- case '.flac':
- $mime_type = 'audio/flac';
- break;
- case '.gif':
- $mime_type = 'image/gif';
- break;
- case '.gzip':
- case '.gz':
- $mime_type = 'application/x-gzip';
- break;
- case '.htm':
- case '.html':
- $mime_type = 'text/html';
- break;
- case '.jpeg':
- case '.jpg':
- $mime_type = 'image/jpeg';
- break;
- case '.js':
- $mime_type = 'application/x-javascript';
- break;
- case '.oga':
- case '.ogg':
- $mime_type = 'audio/ogg';
- break;
- case '.ogv':
- $mime_type = 'video/ogg';
- break;
- case '.pdf':
- $mime_type = 'application/pdf';
- break;
- case '.png':
- $mime_type = 'image/png';
- break;
- case '.svg':
- $mime_type = 'image/svg+xml';
- break;
- case '.tar':
- $mime_type = 'application/x-tar';
- break;
- case '.tgz':
- $mime_type = 'application/x-compressed';
- break;
- case '.tif':
- case '.tiff':
- $mime_type = 'image/tiff';
- break;
- case '.txt':
- $mime_type = 'text/plain';
- break;
- case '.zip':
- $mime_type = 'application/zip';
- break;
- default:
- $mime_type = 'application/octet-stream';
- break;
+ // Fallback solution: (try to guess the type by the file extension
+ if(!self::$mimetypes){
+ self::$mimetypes=include('mimetypes.list.php');
}
+ $extention=strtolower(strrchr(basename($fspath), "."));
+ $extention=substr($extention,1);//remove leading .
+ $mime_type=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
}
-
return $mime_type;
}
}