. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Factory; 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 = Factory::filesystem()->data(); $path = $request->getAttribute('path'); return Factory::image()->fileResponse($filesystem, $path, false); } }