mirror of
https://github.com/YGGverse/gemini-php.git
synced 2026-03-31 17:05:29 +00:00
add getMimeByPath method
This commit is contained in:
parent
4d9ec32986
commit
82085aa8c3
2 changed files with 24 additions and 0 deletions
12
README.md
12
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
|
#### Filesystem::getDataByPath
|
||||||
|
|
||||||
Return file content if path match storage item
|
Return file content if path match storage item
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,18 @@ class Filesystem
|
||||||
return $path;
|
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
|
public function getDataByPath(?string $path): ?string
|
||||||
{
|
{
|
||||||
if (in_array($path, $this->_list) && is_file($path) || is_readable($path))
|
if (in_array($path, $this->_list) && is_file($path) || is_readable($path))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue