Merge pull request #20744 from owncloud/oc_helper-getMimeType-cleanup
Remove last occurences of OC_Helper::getMimeType()
This commit is contained in:
commit
3882cc8ef3
|
@ -370,7 +370,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
|
||||||
$stat['size'] = filesize($tmpFile);
|
$stat['size'] = filesize($tmpFile);
|
||||||
$stat['mtime'] = $mTime;
|
$stat['mtime'] = $mTime;
|
||||||
$stat['storage_mtime'] = $mTime;
|
$stat['storage_mtime'] = $mTime;
|
||||||
$stat['mimetype'] = \OC_Helper::getMimeType($tmpFile);
|
$stat['mimetype'] = \OC::$server->getMimeTypeDetector()->detect($tmpFile);
|
||||||
$stat['etag'] = $this->getETag($path);
|
$stat['etag'] = $this->getETag($path);
|
||||||
|
|
||||||
$fileId = $this->getCache()->put($path, $stat);
|
$fileId = $this->getCache()->put($path, $stat);
|
||||||
|
|
|
@ -401,18 +401,6 @@ class OC_Helper {
|
||||||
return \OC::$server->getMimeTypeDetector()->detectPath($path);
|
return \OC::$server->getMimeTypeDetector()->detectPath($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get the mimetype form a local file
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
* @return string
|
|
||||||
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
|
|
||||||
* @deprecated 8.2.0 Use \OC::$server->getMimeTypeDetector()->detect($path)
|
|
||||||
*/
|
|
||||||
static function getMimeType($path) {
|
|
||||||
return \OC::$server->getMimeTypeDetector()->detect($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a secure mimetype that won't expose potential XSS.
|
* Get a secure mimetype that won't expose potential XSS.
|
||||||
*
|
*
|
||||||
|
|
|
@ -278,7 +278,7 @@ class OC_Installer{
|
||||||
}
|
}
|
||||||
|
|
||||||
//detect the archive type
|
//detect the archive type
|
||||||
$mime=OC_Helper::getMimeType($path);
|
$mime = \OC::$server->getMimeTypeDetector()->detect($path);
|
||||||
if ($mime !=='application/zip' && $mime !== 'application/x-gzip' && $mime !== 'application/x-bzip2') {
|
if ($mime !=='application/zip' && $mime !== 'application/x-gzip' && $mime !== 'application/x-bzip2') {
|
||||||
throw new \Exception($l->t("Archives of type %s are not supported", array($mime)));
|
throw new \Exception($l->t("Archives of type %s are not supported", array($mime)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Files {
|
||||||
* @since 5.0.0
|
* @since 5.0.0
|
||||||
*/
|
*/
|
||||||
static function getMimeType( $path ) {
|
static function getMimeType( $path ) {
|
||||||
return(\OC_Helper::getMimeType( $path ));
|
return \OC::$server->getMimeTypeDetector()->detect($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,29 +71,6 @@ class Test_Helper extends \Test\TestCase {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function testGetMimeType() {
|
|
||||||
$dir=OC::$SERVERROOT.'/tests/data';
|
|
||||||
$result = OC_Helper::getMimeType($dir."/");
|
|
||||||
$expected = 'httpd/unix-directory';
|
|
||||||
$this->assertEquals($result, $expected);
|
|
||||||
|
|
||||||
$result = OC_Helper::getMimeType($dir."/data.tar.gz");
|
|
||||||
$expected = 'application/x-gzip';
|
|
||||||
$this->assertEquals($result, $expected);
|
|
||||||
|
|
||||||
$result = OC_Helper::getMimeType($dir."/data.zip");
|
|
||||||
$expected = 'application/zip';
|
|
||||||
$this->assertEquals($result, $expected);
|
|
||||||
|
|
||||||
$result = OC_Helper::getMimeType($dir."/desktopapp.svg");
|
|
||||||
$expected = 'image/svg+xml';
|
|
||||||
$this->assertEquals($result, $expected);
|
|
||||||
|
|
||||||
$result = OC_Helper::getMimeType($dir."/desktopapp.png");
|
|
||||||
$expected = 'image/png';
|
|
||||||
$this->assertEquals($result, $expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testGetSecureMimeType() {
|
function testGetSecureMimeType() {
|
||||||
$dir=OC::$SERVERROOT.'/tests/data';
|
$dir=OC::$SERVERROOT.'/tests/data';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue