33 if (!is_file($filename) || !is_readable($filename)) {
39 $mime = $detector->getType($filename,
$default);
43 'original_filename' => basename($filename),
47 return $this->events->triggerResults(
'mime_type',
'file',
$params, $mime);
62 case 'application/msword':
63 case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
64 case 'application/pdf':
67 case 'application/ogg':
73 if (
preg_match(
'~^(audio|image|video)/~', $mimetype, $matches)) {
77 if (str_starts_with($mimetype,
'text/') || str_contains($mimetype,
'opendocument')) {
82 'mime_type' => $mimetype,
84 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.
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.
__construct(protected EventsService $events)
Constructor.
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.