0
0
mirror of https://github.com/nextcloud/server.git synced 2024-12-29 16:38:28 +00:00
nextcloud_server/apps/settings/lib/Controller/LogSettingsController.php
provokateurin f012c996ee
refactor(settings): Replace security annotations with respective attributes
Signed-off-by: provokateurin <kate@provokateurin.de>
2024-07-27 22:49:43 +02:00

49 lines
1.4 KiB
PHP

<?php
/**
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Settings\Controller;
use OC\Log;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\StreamResponse;
use OCP\IRequest;
class LogSettingsController extends Controller {
/** @var Log */
private $log;
public function __construct(string $appName, IRequest $request, Log $logger) {
parent::__construct($appName, $request);
$this->log = $logger;
}
/**
* download logfile
*
* @psalm-suppress MoreSpecificReturnType The value of Content-Disposition is not relevant
* @psalm-suppress LessSpecificReturnStatement The value of Content-Disposition is not relevant
* @return StreamResponse<Http::STATUS_OK, array{Content-Type: 'application/octet-stream', 'Content-Disposition': string}>
*
* 200: Logfile returned
*/
#[NoCSRFRequired]
public function download() {
if (!$this->log instanceof Log) {
throw new \UnexpectedValueException('Log file not available');
}
$resp = new StreamResponse($this->log->getLogPath());
$resp->setHeaders([
'Content-Type' => 'application/octet-stream',
'Content-Disposition' => 'attachment; filename="nextcloud.log"',
]);
return $resp;
}
}