summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-06-06 23:51:44 +0200
committerRobin Appelman <icewind@owncloud.com>2013-06-06 23:51:44 +0200
commitcf7321915d3913888e03e0624b32296194a91e6e (patch)
tree4a1c30f39cd9711905eff42f492f114f3c5a68ea /lib
parent81b6cab94fcaa5c3bc76a92d38997cd7928cb37d (diff)
downloadnextcloud-server-cf7321915d3913888e03e0624b32296194a91e6e.tar.gz
nextcloud-server-cf7321915d3913888e03e0624b32296194a91e6e.zip
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..c3dc8740ee8 100644
--- a/lib/helper.php
+++ b/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/';