]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use proper public API for OC_Helper::getFileNameMimeType
authorMorris Jobke <hey@morrisjobke.de>
Thu, 17 Dec 2015 16:07:48 +0000 (17:07 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Thu, 17 Dec 2015 16:07:48 +0000 (17:07 +0100)
apps/files_sharing/api/local.php
apps/files_trashbin/ajax/preview.php
apps/files_trashbin/lib/helper.php
apps/files_versions/ajax/preview.php
lib/private/files/objectstore/objectstorestorage.php
lib/private/files/storage/common.php
lib/private/helper.php
tests/lib/helper.php

index aaafafb269f8e4b2f5c7d97756eb8880e3b11600..5b2f2e06e75a0da34d279ed7ce91ea42ca6e12fd 100644 (file)
@@ -64,9 +64,10 @@ class Local {
                if ($shares === false) {
                        return new \OC_OCS_Result(null, 404, 'could not get shares');
                } else {
+                       $mimetypeDetector = \OC::$server->getMimeTypeDetector();
                        foreach ($shares as &$share) {
                                if ($share['item_type'] === 'file' && isset($share['path'])) {
-                                       $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['path']);
+                                       $share['mimetype'] = $mimetypeDetector->detectPath($share['path']);
                                        if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) {
                                                $share['isPreviewAvailable'] = true;
                                        }
@@ -227,9 +228,10 @@ class Local {
        private static function getFilesSharedWithMe() {
                try     {
                        $shares = \OCP\Share::getItemsSharedWith('file');
+                       $mimetypeDetector = \OC::$server->getMimeTypeDetector();
                        foreach ($shares as &$share) {
                                if ($share['item_type'] === 'file') {
-                                       $share['mimetype'] = \OC_Helper::getFileNameMimeType($share['file_target']);
+                                       $share['mimetype'] = $mimetypeDetector->detectPath($share['file_target']);
                                        if (\OC::$server->getPreviewManager()->isMimeSupported($share['mimetype'])) {
                                                $share['isPreviewAvailable'] = true;
                                        }
index 49d6d93f57411b236e4f0fd88b9d57b16925d412..ecb4971253f40522f27470c86f10c9363814b305 100644 (file)
@@ -62,7 +62,7 @@ try{
                                $fileName = substr($fileName, 0, $i);
                        }
                }
-               $mimetype = \OC_Helper::getFileNameMimeType($fileName);
+               $mimetype = \OC::$server->getMimeTypeDetector()->detectPath($fileName);
        }
        $preview->setMimetype($mimetype);
        $preview->setMaxX($maxX);
index d14e97285c542a922fb728e381bea59ef897dd18..0ccf15cd2bc1357f854b11111b8310ae365d21a8 100644 (file)
@@ -87,7 +87,7 @@ class Helper
                                        $i = array(
                                                'name' => $id,
                                                'mtime' => $timestamp,
-                                               'mimetype' => $view->is_dir($dir . '/' . $entryName) ? 'httpd/unix-directory' : \OC_Helper::getFileNameMimeType($id),
+                                               'mimetype' => $view->is_dir($dir . '/' . $entryName) ? 'httpd/unix-directory' : \OC::$server->getMimeTypeDetector()->detectPath($id),
                                                'type' => $view->is_dir($dir . '/' . $entryName) ? 'dir' : 'file',
                                                'directory' => ($dir === '/') ? '' : $dir,
                                                'size' => $size,
index 0da518f3eaaa96417245131e47727ce7fca52f78..f21911abc9b44ba2248c15f193846db04bf0b35a 100644 (file)
@@ -48,7 +48,7 @@ if($maxX === 0 || $maxY === 0) {
 try {
        list($user, $file) = \OCA\Files_Versions\Storage::getUidAndFilename($file);
        $preview = new \OC\Preview($user, 'files_versions', $file.'.v'.$version);
-       $mimetype = \OC_Helper::getFileNameMimeType($file);
+       $mimetype = \OC::$server->getMimeTypeDetector()->detectPath($file);
        $preview->setMimetype($mimetype);
        $preview->setMaxX($maxX);
        $preview->setMaxY($maxY);
index 5ec05a3529eeebdc108a5ca4620bba77a6453dc7..a053ea6d6d2ea75b0f67f805f8b5d6a89577d7d8 100644 (file)
@@ -329,7 +329,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
                        $stat['mtime'] = $mtime;
                        $this->getCache()->update($stat['fileid'], $stat);
                } else {
-                       $mimeType = \OC_Helper::getFileNameMimeType($path);
+                       $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
                        // create new file
                        $stat = array(
                                'etag' => $this->getETag($path),
index b06543d0a6a6d4581d90562a614100b530a2e815..091f2edb6297df9d80a0f4eb1e924c6005e68598 100644 (file)
@@ -225,7 +225,7 @@ abstract class Common implements Storage {
                if ($this->is_dir($path)) {
                        return 'httpd/unix-directory';
                } elseif ($this->file_exists($path)) {
-                       return \OC_Helper::getFileNameMimeType($path);
+                       return \OC::$server->getMimeTypeDetector()->detectPath($path);
                } else {
                        return false;
                }
index 779a67a2340232d7ee170b6b24385fb4a9dd62d6..c13ac1990dd973762ca8c4453a9c1417fbfb46a4 100644 (file)
@@ -348,14 +348,6 @@ class OC_Helper {
                return !file_exists($dir);
        }
 
-       /**
-        * @return \OC\Files\Type\Detection
-        * @deprecated 8.2.0 use \OC::$server->getMimeTypeDetector()
-        */
-       static public function getMimetypeDetector() {
-               return \OC::$server->getMimeTypeDetector();
-       }
-
        /**
         * @return \OC\Files\Type\TemplateManager
         */
index 469ffecc773c4a49380ed5c7caf81b1309886b51..51f7342f45662ac9e8b7ea97f4ba0142a4c2149e 100644 (file)
@@ -83,15 +83,6 @@ class Test_Helper extends \Test\TestCase {
                $this->assertEquals($result, $expected);
        }
 
-       function testGetFileNameMimeType() {
-               $this->assertEquals('text/plain', OC_Helper::getFileNameMimeType('foo.txt'));
-               $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.png'));
-               $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.bar.png'));
-               $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('.png'));
-               $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('foo'));
-               $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType(''));
-       }
-
        function testGetStringMimeType() {
                if (\OC_Util::runningOnWindows()) {
                        $this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows');