summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-04-18 20:24:22 +0200
committerRobin Appelman <icewind@owncloud.com>2012-04-18 20:54:28 +0200
commitbdb3962b8dc42493a9db87882d1671d6d3a53eea (patch)
tree1eda45e511576048a1a1a4a8e3805a9919be02ec /lib/helper.php
parentd1ad4dc8d60a656606b6c237df9f4c931f828c73 (diff)
downloadnextcloud-server-bdb3962b8dc42493a9db87882d1671d6d3a53eea.tar.gz
nextcloud-server-bdb3962b8dc42493a9db87882d1671d6d3a53eea.zip
add function to get mimetype from string
Diffstat (limited to 'lib/helper.php')
-rwxr-xr-xlib/helper.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index eed94917767..beb10280d93 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -354,6 +354,26 @@ class OC_Helper {
}
/**
+ * get the mimetype form a data string
+ * @param string data
+ * @return string
+ */
+ static function getStringMimeType($data){
+ if(function_exists('finfo_open') and function_exists('finfo_file')){
+ $finfo=finfo_open(FILEINFO_MIME);
+ return finfo_buffer($finfo, $data);
+ }else{
+ $tmpFile=OC_Helper::tmpFile();
+ $fh=fopen($tmpFile,'wb');
+ fwrite($fh,$data,8024);
+ fclose($fh);
+ $mime=self::getMimeType($tmpFile);
+ unset($tmpFile);
+ return $mime;
+ }
+ }
+
+ /**
* @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d.
* @param $s name of the var to escape, if set.
* @param $d default value.