mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
update MIME type detection
This commit is contained in:
parent
bf9b7cbc93
commit
0183d4dbb4
2 changed files with 29 additions and 22 deletions
|
|
@ -86,31 +86,24 @@ class File
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_connection->setMime(
|
// Detect MIME type
|
||||||
strval(
|
switch (true)
|
||||||
mime_content_type(
|
|
||||||
$address->getPath()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Filesystem::MIME_TEXT_PLAIN == $this->_connection->getMime())
|
|
||||||
{
|
{
|
||||||
$extension = pathinfo(
|
case $mime = Filesystem::getMimeByPath(
|
||||||
strval(
|
$address->getPath()
|
||||||
$address->getPath()
|
): break;
|
||||||
),
|
|
||||||
PATHINFO_EXTENSION
|
|
||||||
);
|
|
||||||
|
|
||||||
if (in_array($extension, ['gmi', 'gemini']))
|
case $mime = mime_content_type(
|
||||||
{
|
$address->getPath()
|
||||||
$this->_connection->setMime(
|
): break;
|
||||||
Filesystem::MIME_TEXT_GEMINI
|
|
||||||
);
|
default: $mime = Filesystem::MIME_TEXT_GEMINI;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_connection->setMime(
|
||||||
|
$mime
|
||||||
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,22 @@ class Nex
|
||||||
$response
|
$response
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Detect MIME type
|
||||||
|
switch (true)
|
||||||
|
{
|
||||||
|
case $mime = Filesystem::getMimeByPath(
|
||||||
|
$address->getPath()
|
||||||
|
): break;
|
||||||
|
|
||||||
|
case $mime = Filesystem::getMimeByData(
|
||||||
|
$response
|
||||||
|
): break;
|
||||||
|
|
||||||
|
default: $mime = Filesystem::MIME_TEXT_PLAIN;
|
||||||
|
}
|
||||||
|
|
||||||
$this->_connection->setMime(
|
$this->_connection->setMime(
|
||||||
Filesystem::MIME_TEXT_PLAIN
|
$mime
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue