Elgg  Version 2.3
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Elgg\Filesystem\MimeTypeDetector Class Reference

Detect the MIME type of a file. More...

Public Member Functions

 getType ($file, $default=self::DEFAULT_TYPE)
 Sniff the MIME type. More...
 
 tryStrategies ($file)
 Detect MIME type using various strategies. More...
 
 fixDetectionErrors ($type, $extension)
 Fix common type detection errors. More...
 

Static Public Member Functions

static tryFinfo ($file)
 Detect MIME type using finfo_open. More...
 
static tryMimeContentType ($file)
 Detect MIME type using mime_content_type. More...
 
static tryFile ($file)
 Detect MIME type using file(1) More...
 
static tryGetimagesize ($file)
 Detect MIME type. More...
 

Public Attributes

const DEFAULT_TYPE = 'application/octet-stream'
 
 $strategies
 
 $use_extension = true
 
 $extensions
 

Detailed Description

Detect the MIME type of a file.

Definition at line 7 of file MimeTypeDetector.php.

Member Function Documentation

Elgg\Filesystem\MimeTypeDetector::fixDetectionErrors (   $type,
  $extension 
)

Fix common type detection errors.

Parameters
string$typeMIME type detected
string$extensionFilename extensions
Returns
string Fixed MIME type

Definition at line 160 of file MimeTypeDetector.php.

Elgg\Filesystem\MimeTypeDetector::getType (   $file,
  $default = self::DEFAULT_TYPE 
)

Sniff the MIME type.

Parameters
string$fileFile path
string$defaultDefault type to return on failure
Returns
string MIME type

Definition at line 115 of file MimeTypeDetector.php.

static Elgg\Filesystem\MimeTypeDetector::tryFile (   $file)
static

Detect MIME type using file(1)

Parameters
string$fileFile path
Returns
string Type detected. Empty string on failure

Definition at line 223 of file MimeTypeDetector.php.

static Elgg\Filesystem\MimeTypeDetector::tryFinfo (   $file)
static

Detect MIME type using finfo_open.

Parameters
string$fileFile path
Returns
string Type detected. Empty string on failure

Definition at line 192 of file MimeTypeDetector.php.

static Elgg\Filesystem\MimeTypeDetector::tryGetimagesize (   $file)
static

Detect MIME type.

Parameters
string$fileFile path
Returns
string Type detected. Empty string on failure

Definition at line 237 of file MimeTypeDetector.php.

static Elgg\Filesystem\MimeTypeDetector::tryMimeContentType (   $file)
static

Detect MIME type using mime_content_type.

Parameters
string$fileFile path
Returns
string Type detected. Empty string on failure

Definition at line 213 of file MimeTypeDetector.php.

Elgg\Filesystem\MimeTypeDetector::tryStrategies (   $file)

Detect MIME type using various strategies.

Parameters
string$fileFile path
Returns
string Type detected. Empty string on failure

Definition at line 142 of file MimeTypeDetector.php.

Member Data Documentation

Elgg\Filesystem\MimeTypeDetector::$extensions

Definition at line 29 of file MimeTypeDetector.php.

Elgg\Filesystem\MimeTypeDetector::$strategies
Initial value:
= [
[__CLASS__, 'tryFinfo'],
[__CLASS__, 'tryMimeContentType'],
[__CLASS__, 'tryFile'],
[__CLASS__, 'tryGetimagesize'],
]

Definition at line 14 of file MimeTypeDetector.php.

Elgg\Filesystem\MimeTypeDetector::$use_extension = true

Definition at line 24 of file MimeTypeDetector.php.

const Elgg\Filesystem\MimeTypeDetector::DEFAULT_TYPE = 'application/octet-stream'

Definition at line 9 of file MimeTypeDetector.php.


The documentation for this class was generated from the following file: