本文整理汇总了PHP中OC_Helper::getStringMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Helper::getStringMimeType方法的具体用法?PHP OC_Helper::getStringMimeType怎么用?PHP OC_Helper::getStringMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Helper
的用法示例。
在下文中一共展示了OC_Helper::getStringMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetStringMimeType
function testGetStringMimeType()
{
if (\OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] Strings have mimetype application/octet-stream on Windows');
}
$result = OC_Helper::getStringMimeType("/data/data.tar.gz");
$expected = 'text/plain; charset=us-ascii';
$this->assertEquals($result, $expected);
}
示例2: testGetStringMimeType
function testGetStringMimeType()
{
$result = OC_Helper::getStringMimeType("/data/data.tar.gz");
$expected = 'text/plain; charset=us-ascii';
$this->assertEquals($result, $expected);
}
示例3: _guess_content_type
/**
* Internal check to get the proper mimetype.
*
* This function would go over the available PHP methods to get
* the MIME type.
*
* By default it will try to use the PHP fileinfo library which is
* available from PHP 5.3 or as an PECL extension
* (http://pecl.php.net/package/Fileinfo).
*
* It will get the magic file by default from the system wide file
* which is usually available in /usr/share/magic on Unix or try
* to use the file specified in the source directory of the API
* (share directory).
*
* if fileinfo is not available it will try to use the internal
* mime_content_type function.
*
* @param string $handle name of file or buffer to guess the type from
* @return boolean <kbd>True</kbd> if successful
* @throws BadContentTypeException
*/
function _guess_content_type($handle)
{
if ($this->content_type) {
return;
}
// if (function_exists("finfo_open")) {
// $local_magic = dirname(__FILE__) . "/share/magic";
// $finfo = @finfo_open(FILEINFO_MIME, $local_magic);
//
// if (!$finfo)
// $finfo = @finfo_open(FILEINFO_MIME);
//
// if ($finfo) {
//
// if (is_file((string)$handle))
// $ct = @finfo_file($finfo, $handle);
// else
// $ct = @finfo_buffer($finfo, $handle);
//
// /* PHP 5.3 fileinfo display extra information like
// charset so we remove everything after the ; since
// we are not into that stuff */
// if ($ct) {
// $extra_content_type_info = strpos($ct, "; ");
// if ($extra_content_type_info)
// $ct = substr($ct, 0, $extra_content_type_info);
// }
//
// if ($ct && $ct != 'application/octet-stream')
// $this->content_type = $ct;
//
// @finfo_close($finfo);
// }
// }
//
// if (!$this->content_type && (string)is_file($handle) && function_exists("mime_content_type")) {
// $this->content_type = @mime_content_type($handle);
// }
//use OC's mimetype detection for files
if (is_file($handle)) {
$this->content_type = OC_Helper::getMimeType($handle);
} else {
$this->content_type = OC_Helper::getStringMimeType($handle);
}
if (!$this->content_type) {
throw new BadContentTypeException("Required Content-Type not set");
}
return True;
}