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;
}
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;
}
$fileName = substr($fileName, 0, $i);
}
}
- $mimetype = \OC_Helper::getFileNameMimeType($fileName);
+ $mimetype = \OC::$server->getMimeTypeDetector()->detectPath($fileName);
}
$preview->setMimetype($mimetype);
$preview->setMaxX($maxX);
$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,
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);
$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),
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;
}
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
*/
$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');