1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-29 02:10:20 +02:00

v2.1.0 fix download response if no file found

This commit is contained in:
trendschau
2024-01-05 19:49:44 +01:00
parent af5f633aa7
commit caf2b98921

View File

@@ -2,18 +2,20 @@
namespace Typemill\Controllers;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Typemill\Models\StorageWrapper;
use Typemill\Static\Translations;
class ControllerWebDownload extends Controller
{
public function download($request, $response, $args)
public function download(Request $request, Response $response, $args)
{
$filename = isset($args['params']) ? $args['params'] : false;
if(!$filename)
{
$response->getBody()->write(Translations::translate('the requested file does not exist.'))->withStatus(404);
return $response;
$response->getBody()->write(Translations::translate('the requested file does not exist.'));
return $response->withStatus(404);
}
$storage = new StorageWrapper('\Typemill\Models\Storage');
@@ -26,8 +28,8 @@ class ControllerWebDownload extends Controller
$allowedFiletypes = [];
if(!$this->validate($filepath, $filename, $allowedFiletypes))
{
$response->getBody()->write(Translations::translate('the requested filetype does not exist.'))->withStatus(404);
return $response;
$response->getBody()->write(Translations::translate('the requested filetype does not exist.'));
return $response->withStatus(404);
}
if($restrictions && isset($restrictions[$filefolder . $filename]))