]> source.dussan.org Git - nextcloud-server.git/commitdiff
added a file to fix wrong recognised mime-types
authorGeorg Ehrke <dev@georgswebsite.de>
Thu, 12 Jan 2012 17:26:13 +0000 (18:26 +0100)
committerGeorg Ehrke <dev@georgswebsite.de>
Thu, 12 Jan 2012 17:26:13 +0000 (18:26 +0100)
lib/filestorage/local.php
lib/mimetypes.fixlist.php [new file with mode: 0644]

index cfc27159786e5844638a55237eb93a7b01342be5..1261bd3aa83aa230620ae19c1f3e71b278feaac6 100644 (file)
@@ -132,6 +132,13 @@ class OC_Filestorage_Local extends OC_Filestorage{
        public function getMimeType($fspath){
                if($this->is_readable($fspath)){
                        $mimeType='application/octet-stream';
+                       if ($mimeType=='application/octet-stream') {
+                               self::$mimetypes = include('mimetypes.fixlist.php');
+                               $extention=strtolower(strrchr(basename($fspath), "."));
+                               $extention=substr($extention,1);//remove leading .
+                               $mimeType=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
+                               
+                       }
                        if (@is_dir($this->datadir.$fspath)) {
                                // directories are easy
                                return "httpd/unix-directory";
@@ -158,7 +165,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
                        }
                        if ($mimeType=='application/octet-stream') {
                                // Fallback solution: (try to guess the type by the file extension
-                               if(!self::$mimetypes){
+                               if(!self::$mimetypes || self::$mimetypes == include('mimetypes.list.php')){
                                        self::$mimetypes=include('mimetypes.list.php');
                                }
                                $extention=strtolower(strrchr(basename($fspath), "."));
diff --git a/lib/mimetypes.fixlist.php b/lib/mimetypes.fixlist.php
new file mode 100644 (file)
index 0000000..f2d86d0
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+return array(
+       'ics'=>'text/calendar',
+       'ical'=>'text/calendar',
+       'js'=>'application/javascript',
+       'odt'=>'application/vnd.oasis.opendocument.text',
+       'ods'=>'application/vnd.oasis.opendocument.spreadsheet',
+       'odg'=>'application/vnd.oasis.opendocument.graphics',
+       'odp'=>'application/vnd.oasis.opendocument.presentation',
+       'pl'=>'text/x-script.perl',
+       'py'=>'text/x-script.phyton',
+);