Fixed progress showing as int instead of human-readable in index and backend view. Added Download entire logfile button.

This commit is contained in:
abdulmohsen
2024-05-13 13:06:19 +03:00
parent d3999541c6
commit 686d6bb82f
5 changed files with 55 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ use App\Libs\DataUtil;
use App\Libs\HTTP_STATUS;
use App\Libs\Stream;
use App\Libs\StreamClosure;
use finfo;
use LimitIterator;
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface as iResponse;
@@ -129,6 +130,9 @@ final class Index
$file = new SplFileObject($filePath, 'r');
if (true === (bool)$params->get('download')) {
return $this->download($filePath);
}
if ($params->get('stream')) {
return $this->stream($filePath);
}
@@ -167,6 +171,20 @@ final class Index
);
}
private function download(string $filePath): iResponse
{
$mime = (new finfo(FILEINFO_MIME_TYPE))->file($filePath);
return new Response(
status: HTTP_STATUS::HTTP_OK->value,
headers: [
'Content-Type' => false === $mime ? 'application/octet-stream' : $mime,
'Content-Length' => filesize($filePath),
],
body: stream::make($filePath, 'r')
);
}
private function stream(string $filePath): iResponse
{
ini_set('max_execution_time', '3601');