16577bfc3SGreg Roach<?php 26577bfc3SGreg Roach 36577bfc3SGreg Roach/** 46577bfc3SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 66577bfc3SGreg Roach * This program is free software: you can redistribute it and/or modify 76577bfc3SGreg Roach * it under the terms of the GNU General Public License as published by 86577bfc3SGreg Roach * the Free Software Foundation, either version 3 of the License, or 96577bfc3SGreg Roach * (at your option) any later version. 106577bfc3SGreg Roach * This program is distributed in the hope that it will be useful, 116577bfc3SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 126577bfc3SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 136577bfc3SGreg Roach * GNU General Public License for more details. 146577bfc3SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 166577bfc3SGreg Roach */ 176577bfc3SGreg Roach 186577bfc3SGreg Roachdeclare(strict_types=1); 196577bfc3SGreg Roach 206577bfc3SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 216577bfc3SGreg Roach 226b9cb339SGreg Roachuse Fisharebest\Webtrees\Registry; 23b55cbc6bSGreg Roachuse Fisharebest\Webtrees\Validator; 246577bfc3SGreg Roachuse Psr\Http\Message\ResponseInterface; 256577bfc3SGreg Roachuse Psr\Http\Message\ServerRequestInterface; 266577bfc3SGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 276577bfc3SGreg Roach 286577bfc3SGreg Roach/** 296577bfc3SGreg Roach * Download a media file. 306577bfc3SGreg Roach */ 316577bfc3SGreg Roachclass AdminMediaFileDownload implements RequestHandlerInterface 326577bfc3SGreg Roach{ 336577bfc3SGreg Roach /** 346577bfc3SGreg Roach * Download a non-image media file. 356577bfc3SGreg Roach * 366577bfc3SGreg Roach * @param ServerRequestInterface $request 376577bfc3SGreg Roach * 386577bfc3SGreg Roach * @return ResponseInterface 396577bfc3SGreg Roach */ 406577bfc3SGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 416577bfc3SGreg Roach { 426b9cb339SGreg Roach $filesystem = Registry::filesystem()->data(); 43b55cbc6bSGreg Roach $path = Validator::queryParams($request)->string('path'); 446577bfc3SGreg Roach 456b9cb339SGreg Roach return Registry::imageFactory()->fileResponse($filesystem, $path, false); 466577bfc3SGreg Roach } 476577bfc3SGreg Roach} 48