aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-12-17 17:07:48 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-12-17 17:07:48 +0100
commitecdf88e41b898889fe8e05bb9c05415dd6b03a95 (patch)
tree735f9198dad871e9dd6459f4ccd5dc986937c594
parent3818a055b96a528263585b93f598fb479b5a1ec4 (diff)
downloadnextcloud-server-ecdf88e41b898889fe8e05bb9c05415dd6b03a95.tar.gz
nextcloud-server-ecdf88e41b898889fe8e05bb9c05415dd6b03a95.zip
Use proper public API for OC_Helper::getFileNameMimeType
-rw-r--r--apps/files_sharing/api/local.php6
-rw-r--r--apps/files_trashbin/ajax/preview.php2
-rw-r--r--apps/files_trashbin/lib/helper.php2
-rw-r--r--apps/files_versions/ajax/preview.php2
-rw-r--r--lib/private/files/objectstore/objectstorestorage.php2
-rw-r--r--lib/private/files/storage/common.php2
-rw-r--r--lib/private/helper.php8
-rw-r--r--tests/lib/helper.php9
8 files changed, 9 insertions, 24 deletions
diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php
index aaafafb269f..5b2f2e06e75 100644
--- a/apps/files_sharing/api/local.php
+++ b/apps/files_sharing/api/local.php
@@ -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;
}
diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php
index 49d6d93f574..ecb4971253f 100644
--- a/apps/files_trashbin/ajax/preview.php
+++ b/apps/files_trashbin/ajax/preview.php
@@ -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);
diff --git a/apps/files_trashbin/lib/helper.php b/apps/files_trashbin/lib/helper.php
index d14e97285c5..0ccf15cd2bc 100644
--- a/apps/files_trashbin/lib/helper.php
+++ b/apps/files_trashbin/lib/helper.php
@@ -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,
diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php
index 0da518f3eaa..f21911abc9b 100644
--- a/apps/files_versions/ajax/preview.php
+++ b/apps/files_versions/ajax/preview.php
@@ -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);
diff --git a/lib/private/files/objectstore/objectstorestorage.php b/lib/private/files/objectstore/objectstorestorage.php
index 5ec05a3529e..a053ea6d6d2 100644
--- a/lib/private/files/objectstore/objectstorestorage.php
+++ b/lib/private/files/objectstore/objectstorestorage.php
@@ -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),
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index b06543d0a6a..091f2edb629 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -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;
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 779a67a2340..c13ac1990dd 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -349,14 +349,6 @@ class OC_Helper {
}
/**
- * @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
*/
static public function getFileTemplateManager() {
diff --git a/tests/lib/helper.php b/tests/lib/helper.php
index 469ffecc773..51f7342f456 100644
--- a/tests/lib/helper.php
+++ b/tests/lib/helper.php
@@ -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');