lib/private/Files/Type/Detection.php
/**
	 * detect mimetype based on the content of a string
	 *
	 * @param string $data
	 * @return string
	 */
detect mimetype based on the content of a string
@param string $data
@return string
detect mimetype based on the content of a string @param string $data @return string
public function detectString($data) {
		if (function_exists('finfo_open') and function_exists('finfo_file')) {
			$finfo = finfo_open(FILEINFO_MIME);
			$info = finfo_buffer($finfo, $data);
			return strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
		} else {
			$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
			$fh = fopen($tmpFile, 'wb');
			fwrite($fh, $data, 8024);
			fclose($fh);
			$mime = $this->detect($tmpFile);
			unset($tmpFile);
			return $mime;
		}
	}
public function detectString ( $ data ) { if ( function_exists ( 'finfo_open' ) and function_exists ( 'finfo_file' ) ) { $ finfo = finfo_open ( FILEINFO_MIME ) ; $ info = finfo_buffer ( $ finfo , $ data ) ; return strpos ( $ info , ';' ) !== false ? substr ( $ info , 0 , strpos ( $ info , ';' ) ) : $ info ; } else { $ tmpFile = \ OC :: $ server -> getTempManager ( ) -> getTemporaryFile ( ) ; $ fh = fopen ( $ tmpFile , 'wb' ) ; fwrite ( $ fh , $ data , 8024 ) ; fclose ( $ fh ) ; $ mime = $ this -> detect ( $ tmpFile ) ; unset ( $ tmpFile ) ; return $ mime ; } }
detect mimetype based on the content of a string
 @param string $data
 @return string
detect mimetype based on the content of a string @param string $data @return string