Detection

class OC\Files\Type\Detection
Class Detection
Mimetype detection
Source:lib/private/Files/Type/Detection.php#56
Implements:OCP\Files\IMimeTypeDetector

Constants

CUSTOM_MIMETYPEMAPPING = mimetypemapping.json
Source:lib/private/Files/Type/Detection.php#57
CUSTOM_MIMETYPEALIASES = mimetypealiases.json
Source:lib/private/Files/Type/Detection.php#58

Properties

protected static property OC\Files\Type\Detection::$mimetypes
Source:lib/private/Files/Type/Detection.php#60
protected static property OC\Files\Type\Detection::$secureMimeTypes
Source:lib/private/Files/Type/Detection.php#61
protected static property OC\Files\Type\Detection::$mimetypeIcons
Source:lib/private/Files/Type/Detection.php#63
protected static property OC\Files\Type\Detection::$mimeTypeAlias
Source:lib/private/Files/Type/Detection.php#65
Type:string[]

Methods

public OC\Files\Type\Detection::__construct($urlGenerator, $logger, $customConfigDir, $defaultConfigDir)
Source:

lib/private/Files/Type/Detection.php#85

Parameters:
public OC\Files\Type\Detection::registerType($extension, $mimetype, $secureMimeType=null)
Add an extension -> mimetype mapping
$mimetype is the assumed correct mime type
The optional $secureMimeType is an alternative to send to send
to avoid potential XSS.
Source:

lib/private/Files/Type/Detection.php#106

Parameters:
  • $extension (string)
  • $mimetype (string)
  • $secureMimeType (string | null)
public OC\Files\Type\Detection::registerTypeArray($types)
Add an array of extension -> mimetype mappings
The mimetype value is in itself an array where the first index is
the assumed correct mimetype and the second is either a secure alternative
or null if the correct is considered secure.
Source:

lib/private/Files/Type/Detection.php#122

Parameters:
  • $types (array)
public OC\Files\Type\Detection::getAllAliases()
Source:lib/private/Files/Type/Detection.php#164
Returns:string[]
public OC\Files\Type\Detection::getOnlyDefaultAliases()
Source:lib/private/Files/Type/Detection.php#169
public OC\Files\Type\Detection::getAllMappings()
Source:lib/private/Files/Type/Detection.php#192
Returns:array
public OC\Files\Type\Detection::detectPath($path)
detect mimetype only based on filename, content of file is not used
Source:

lib/private/Files/Type/Detection.php#203

Parameters:
  • $path (string)
Returns:

string

public OC\Files\Type\Detection::detectContent($path)
detect mimetype only based on the content of file
Source:

lib/private/Files/Type/Detection.php#235

Parameters:
  • $path (string)
Returns:

string

Since:

18.0.0

public OC\Files\Type\Detection::detect($path)
detect mimetype based on both filename and content
Source:

lib/private/Files/Type/Detection.php#300

Parameters:
  • $path (string)
Returns:

string

public OC\Files\Type\Detection::detectString($data)
detect mimetype based on the content of a string
Source:

lib/private/Files/Type/Detection.php#316

Parameters:
  • $data (string)
Returns:

string

public OC\Files\Type\Detection::getSecureMimeType($mimeType)
Get a secure mimetype that won’t expose potential XSS.
Source:

lib/private/Files/Type/Detection.php#338

Parameters:
  • $mimeType (string)
Returns:

string

public OC\Files\Type\Detection::mimeTypeIcon($mimetype)
Get path to the icon of a file type
Source:

lib/private/Files/Type/Detection.php#349

Parameters:
  • $mimetype (string) the MIME type
Returns:

string the url