summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-06-16 13:14:16 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-06-16 13:14:16 -0700
commite013e7adea7ce1759e0b65786285c96d0c41e153 (patch)
tree4f08f54937d692a3e199694b36b530b247efcd79 /lib
parent8243d19050d231aecc6102154a625e0308b37a34 (diff)
parentd42f7b85f3d6ec524d1144a599edf3b67e88b1a1 (diff)
downloadnextcloud-server-e013e7adea7ce1759e0b65786285c96d0c41e153.tar.gz
nextcloud-server-e013e7adea7ce1759e0b65786285c96d0c41e153.zip
Merge pull request #3621 from owncloud/path-mimetype
seperate mimetype guessing from filename
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php34
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 225e9fd2a9a..a315c640d1a 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -364,6 +364,26 @@ class OC_Helper {
}
/**
+ * Try to guess the mimetype based on filename
+ *
+ * @param string $path
+ * @return string
+ */
+ static public function getFileNameMimeType($path){
+ if(strpos($path, '.')) {
+ //try to guess the type by the file extension
+ if(!self::$mimetypes || self::$mimetypes != include 'mimetypes.list.php') {
+ self::$mimetypes=include 'mimetypes.list.php';
+ }
+ $extension=strtolower(strrchr(basename($path), "."));
+ $extension=substr($extension, 1);//remove leading .
+ return (isset(self::$mimetypes[$extension]))?self::$mimetypes[$extension]:'application/octet-stream';
+ }else{
+ return 'application/octet-stream';
+ }
+ }
+
+ /**
* get the mimetype form a local file
* @param string $path
* @return string
@@ -377,17 +397,7 @@ class OC_Helper {
return "httpd/unix-directory";
}
- if(strpos($path, '.')) {
- //try to guess the type by the file extension
- if(!self::$mimetypes || self::$mimetypes != include 'mimetypes.list.php') {
- self::$mimetypes=include 'mimetypes.list.php';
- }
- $extension=strtolower(strrchr(basename($path), "."));
- $extension=substr($extension, 1);//remove leading .
- $mimeType=(isset(self::$mimetypes[$extension]))?self::$mimetypes[$extension]:'application/octet-stream';
- }else{
- $mimeType='application/octet-stream';
- }
+ $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/';