Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-16 00:44:58 +0400
committerRobin Appelman <icewind@owncloud.com>2012-02-21 23:48:48 +0400
commitd9c7e4c333f858efaaee35d26ea12733d29bd694 (patch)
treef7180a1491409efc5dc7e5442326c6928ed33ff1 /lib/filestorage
parent325858e9e239b726a207ac150404863df509935c (diff)
proper mimetypes for encrypted files
Diffstat (limited to 'lib/filestorage')
-rw-r--r--lib/filestorage/local.php47
1 files changed, 3 insertions, 44 deletions
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index de1f83e3e14..6f4f68c503d 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -122,50 +122,9 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $return;
}
- public function getMimeType($fspath){
- if($this->is_readable($fspath)){
- $mimeType='application/octet-stream';
- if ($mimeType=='application/octet-stream') {
- self::$mimetypes = include('mimetypes.fixlist.php');
- $extention=strtolower(strrchr(basename($fspath), "."));
- $extention=substr($extention,1);//remove leading .
- $mimeType=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
-
- }
- if (@is_dir($this->datadir.$fspath)) {
- // directories are easy
- return "httpd/unix-directory";
- }
- if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)){
- $mimeType =strtolower(finfo_file($finfo,$this->datadir.$fspath));
- $mimeType=substr($mimeType,0,strpos($mimeType,';'));
- finfo_close($finfo);
- }
- if ($mimeType=='application/octet-stream' && function_exists("mime_content_type")) {
- // use mime magic extension if available
- $mimeType = mime_content_type($this->datadir.$fspath);
- }
- if ($mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) {
- // it looks like we have a 'file' command,
- // lets see it it does have mime support
- $fspath=str_replace("'","\'",$fspath);
- $fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r");
- $reply = fgets($fp);
- pclose($fp);
-
- //trim the character set from the end of the response
- $mimeType=substr($reply,0,strrpos($reply,' '));
- }
- if ($mimeType=='application/octet-stream') {
- // Fallback solution: (try to guess the type by the file extension
- if(!self::$mimetypes || self::$mimetypes != include('mimetypes.list.php')){
- self::$mimetypes=include('mimetypes.list.php');
- }
- $extention=strtolower(strrchr(basename($fspath), "."));
- $extention=substr($extention,1);//remove leading .
- $mimeType=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
- }
- return $mimeType;
+ public function getMimeType($path){
+ if($this->is_readable($path)){
+ return OC_Helper::getMimeType($this->datadir.$path);
}else{
return false;
}