diff --git a/README.md b/README.md index c8ca921..31bff03 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,18 @@ var_dump ( ); ``` +#### Filesystem::getMimeByPath + +Return file MIME if path match storage item + +``` +var_dump ( + $filesystem->getMimeByPath( + '/full/path/to/page.txt' + ) +); +``` + #### Filesystem::getDataByPath Return file content if path match storage item diff --git a/src/Dokuwiki/Filesystem.php b/src/Dokuwiki/Filesystem.php index c132624..77fdc21 100644 --- a/src/Dokuwiki/Filesystem.php +++ b/src/Dokuwiki/Filesystem.php @@ -187,6 +187,18 @@ class Filesystem return $path; } + public function getMimeByPath(?string $path): ?string + { + if (in_array($path, $this->_list) && is_file($path) || is_readable($path)) + { + return mime_content_type( + $path + ); + } + + return null; + } + public function getDataByPath(?string $path): ?string { if (in_array($path, $this->_list) && is_file($path) || is_readable($path))