Detection¶
-
class
OC\Files\Type\
Detection
¶ - Class DetectionMimetype 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: Parameters: - $urlGenerator (
OCP\IURLGenerator
) - $logger (
OCP\ILogger
) - $customConfigDir (string)
- $defaultConfigDir (string)
- $urlGenerator (
-
public
OC\Files\Type\Detection::
registerType
($extension, $mimetype, $secureMimeType=null)¶ - Add an extension -> mimetype mapping$mimetype is the assumed correct mime typeThe optional $secureMimeType is an alternative to send to sendto avoid potential XSS.
Source: Parameters: - $extension (string)
- $mimetype (string)
- $secureMimeType (string | null)
-
public
OC\Files\Type\Detection::
registerTypeArray
($types)¶ - Add an array of extension -> mimetype mappingsThe mimetype value is in itself an array where the first index isthe assumed correct mimetype and the second is either a secure alternativeor null if the correct is considered secure.
Source: 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: Parameters: - $path (string)
Returns: string
-
public
OC\Files\Type\Detection::
detectContent
($path)¶ - detect mimetype only based on the content of file
Source: 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: Parameters: - $path (string)
Returns: string
-
public
OC\Files\Type\Detection::
detectString
($data)¶ - detect mimetype based on the content of a string
Source: Parameters: - $data (string)
Returns: string
-
public
OC\Files\Type\Detection::
getSecureMimeType
($mimeType)¶ - Get a secure mimetype that won’t expose potential XSS.
Source: Parameters: - $mimeType (string)
Returns: string
-
public
OC\Files\Type\Detection::
mimeTypeIcon
($mimetype)¶ - Get path to the icon of a file type
Source: Parameters: - $mimetype (string) the MIME type
Returns: string the url