nextcloud/server · error · OCP\AppFramework\OCS\OCSForbiddenException

Creating direct links is disabled

Error message

Creating direct links is disabled

What it means

Error "Creating direct links is disabled" thrown in nextcloud/server.

Source

Thrown at apps/dav/lib/Controller/DirectController.php:63

		parent::__construct($appName, $request);
	}

	/**
	 * Get a direct link to a file
	 *
	 * @param int $fileId ID of the file
	 * @param int $expirationTime Duration until the link expires
	 * @return DataResponse<Http::STATUS_OK, array{url: string}, array{}>
	 * @throws OCSNotFoundException File not found
	 * @throws OCSBadRequestException Getting direct link is not possible
	 * @throws OCSForbiddenException Missing permissions to get direct link
	 *
	 * 200: Direct link returned
	 */
	#[NoAdminRequired]
	public function getUrl(int $fileId, int $expirationTime = 60 * 60 * 8): DataResponse {
		if (!$this->shareManager->shareApiAllowLinks()) {
			throw new OCSForbiddenException('Creating direct links is disabled');
		}

		$userFolder = $this->rootFolder->getUserFolder($this->userId);

		$file = $userFolder->getFirstNodeById($fileId);

		if (!$file) {
			throw new OCSNotFoundException();
		}

		if ($expirationTime <= 0 || $expirationTime > (60 * 60 * 24)) {
			throw new OCSBadRequestException('Expiration time should be greater than 0 and less than or equal to ' . (60 * 60 * 24));
		}

		if (!($file instanceof File)) {
			throw new OCSBadRequestException('Direct download only works for files');
		}

View on GitHub (pinned to ecdeb153ff)

When it happens

Trigger: Thrown at apps/dav/lib/Controller/DirectController.php:63 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17). Data as JSON: /api/errors/ba3b1d5d56343b74. Report an issue: GitHub.