Using Symfony mime type detection

This commit is contained in:
Christopher Pitt 2015-05-13 19:23:11 +12:00
parent fd917f04a1
commit fbc31692e7
2 changed files with 5 additions and 6 deletions

View File

@ -63,11 +63,9 @@ abstract class FileTextExtractor extends Object {
* @return string Mime type if found
*/
protected static function get_mime($path) {
if(!class_exists('finfo')) return null;
$file = new Symfony\Component\HttpFoundation\File\File($path);
// Check mime of file
$finfo = new finfo(FILEINFO_MIME_TYPE);
return $finfo->file($path);
return $file->getMimeType();
}
/**

View File

@ -20,10 +20,11 @@
"composer/installers": "*",
"silverstripe/framework": "~3.1",
"guzzle/guzzle": "~3.9",
"symfony/event-dispatcher": "~2.6.0@stable"
"symfony/event-dispatcher": "~2.6.0@stable",
"symfony/http-foundation": "~2.6.0"
},
"require-dev": {
"phpunit/PHPUnit": "~3.7@stable"
"phpunit/phpunit": "~3.7"
},
"suggest": {
"ext-fileinfo": "Improved support for file mime detection"