mirror of
https://github.com/YGGverse/gemini-php.git
synced 2025-02-05 11:44:34 +00:00
add getMediaPathByUri method
This commit is contained in:
parent
ba326b9b3c
commit
26d85269e8
12
README.md
12
README.md
@ -174,6 +174,18 @@ var_dump (
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Filesystem::getMediaPathByUri
|
||||||
|
|
||||||
|
Return absolute path to stored media file
|
||||||
|
|
||||||
|
```
|
||||||
|
var_dump (
|
||||||
|
$filesystem->getMediaPathByUri(
|
||||||
|
'hello:world'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
#### Filesystem::getData
|
#### Filesystem::getData
|
||||||
|
|
||||||
Return file content if path match storage item
|
Return file content if path match storage item
|
||||||
|
@ -163,7 +163,31 @@ class Filesystem
|
|||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getData(string $path): ?string
|
public function getMediaPathByUri(string $uri): ?string
|
||||||
|
{
|
||||||
|
$path = sprintf(
|
||||||
|
'%s/media/%s',
|
||||||
|
$this->_path,
|
||||||
|
str_replace(
|
||||||
|
':',
|
||||||
|
'/',
|
||||||
|
mb_strtolower(
|
||||||
|
urldecode(
|
||||||
|
$uri
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!in_array($path, $this->_list) || !is_file($path) || !is_readable($path))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getData(?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…
x
Reference in New Issue
Block a user