Storage::getContentType() 메소드를 MIME 클래스로 이동함

This commit is contained in:
Kijin Sung 2019-10-09 15:20:19 +09:00
parent 9163bc24e9
commit 805a7324cc
4 changed files with 36 additions and 36 deletions

View file

@ -7,6 +7,38 @@ namespace Rhymix\Framework;
*/
class MIME
{
/**
* Get the MIME type of a file, detected by its content.
*
* This method returns the MIME type of a file, or false on error.
*
* @param string $filename
* @return array|false
*/
public static function getContentType($filename)
{
$filename = rtrim($filename, '/\\');
if (Storage::exists($filename) && @is_file($filename) && @is_readable($filename))
{
if (function_exists('mime_content_type'))
{
return @mime_content_type($filename) ?: false;
}
elseif (($image = @getimagesize($filename)) && $image['mime'])
{
return $image['mime'];
}
else
{
return self::getTypeByFilename($filename);
}
}
else
{
return false;
}
}
/**
* Get the MIME type for the given extension.
*