. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Registry; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; /** * Download a media file. */ class AdminMediaFileDownload implements RequestHandlerInterface { /** * Download a non-image media file. * * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $filesystem = Registry::filesystem()->data(); $params = (array) $request->getQueryParams(); $path = $params['path'] ?? ''; return Registry::imageFactory()->fileResponse($filesystem, $path, false); } }