seperate mimetype guessing from filename

remotes/origin/stable6
Robin Appelman 12 years ago
parent 81b6cab94f
commit cf7321915d
  1. 34
      lib/helper.php

@ -364,19 +364,12 @@ class OC_Helper {
}
/**
* get the mimetype form a local file
* @param string $path
* Try to guess the mimetype based on filename
*
* @param string $name
* @return string
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
*/
static function getMimeType($path) {
$isWrapped=(strpos($path, '://')!==false) and (substr($path, 0, 7)=='file://');
if (@is_dir($path)) {
// directories are easy
return "httpd/unix-directory";
}
static public function getFileNameMimeType($name){
if(strpos($path, '.')) {
//try to guess the type by the file extension
if(!self::$mimetypes || self::$mimetypes != include 'mimetypes.list.php') {
@ -388,6 +381,23 @@ class OC_Helper {
}else{
$mimeType='application/octet-stream';
}
}
/**
* get the mimetype form a local file
* @param string $path
* @return string
* does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
*/
static function getMimeType($path) {
$isWrapped=(strpos($path, '://')!==false) and (substr($path, 0, 7)=='file://');
if (@is_dir($path)) {
// directories are easy
return "httpd/unix-directory";
}
$mimeType = self::getFileNameMimeType($path);
if($mimeType=='application/octet-stream' and function_exists('finfo_open')
and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) {
@ -609,7 +619,7 @@ class OC_Helper {
}
/**
* remove all files in PHP /oc-noclean temp dir
* remove all files in PHP /oc-noclean temp dir
*/
public static function cleanTmpNoClean() {
$tmpDirNoCleanFile=get_temp_dir().'/oc-noclean/';

Loading…
Cancel
Save