36 if (!is_file($filename) || !is_readable($filename)) {
42 $mime = $detector->getType($filename,
$default);
46 'original_filename' => basename($filename),
50 return $this->events->triggerResults(
'mime_type',
'file',
$params, $mime);
65 case 'application/msword':
66 case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
67 case 'application/pdf':
70 case 'application/ogg':
76 if (
preg_match(
'~^(audio|image|video)/~', $mimetype, $matches)) {
80 if (str_starts_with($mimetype,
'text/') || str_contains($mimetype,
'opendocument')) {
85 'mime_type' => $mimetype,
87 return $this->events->triggerResults(
'simple_type',
'file',
$params,
$result);
Exception thrown if an argument is not of the expected type.
$params
Saves global plugin settings.
__construct(EventsService $events)
Constructor.
getSimpleType(string $mimetype, string $default= 'general')
Returns the category of a file from its MIME type.
getMimeType(string $filename, string $default=MimeTypeDetector::DEFAULT_TYPE)
Get the mimetype for a given filename.
Detect the MIME type of a file.
Public service related to MIME type detection.
getSimpleTypeFromFile(string $filename, string $default= 'general')
Returns the category of a file from a filename.