{"record":{"id":"ba3b1d5d56343b74","repo":"nextcloud/server","slug":"creating-direct-links-is-disabled","errorCode":null,"errorMessage":"Creating direct links is disabled","messagePattern":"Creating direct links is disabled","errorType":"exception","errorClass":"OCP\\AppFramework\\OCS\\OCSForbiddenException","httpStatus":403,"severity":"error","filePath":"apps/dav/lib/Controller/DirectController.php","lineNumber":63,"sourceCode":"\t\tparent::__construct($appName, $request);\n\t}\n\n\t/**\n\t * Get a direct link to a file\n\t *\n\t * @param int $fileId ID of the file\n\t * @param int $expirationTime Duration until the link expires\n\t * @return DataResponse<Http::STATUS_OK, array{url: string}, array{}>\n\t * @throws OCSNotFoundException File not found\n\t * @throws OCSBadRequestException Getting direct link is not possible\n\t * @throws OCSForbiddenException Missing permissions to get direct link\n\t *\n\t * 200: Direct link returned\n\t */\n\t#[NoAdminRequired]\n\tpublic function getUrl(int $fileId, int $expirationTime = 60 * 60 * 8): DataResponse {\n\t\tif (!$this->shareManager->shareApiAllowLinks()) {\n\t\t\tthrow new OCSForbiddenException('Creating direct links is disabled');\n\t\t}\n\n\t\t$userFolder = $this->rootFolder->getUserFolder($this->userId);\n\n\t\t$file = $userFolder->getFirstNodeById($fileId);\n\n\t\tif (!$file) {\n\t\t\tthrow new OCSNotFoundException();\n\t\t}\n\n\t\tif ($expirationTime <= 0 || $expirationTime > (60 * 60 * 24)) {\n\t\t\tthrow new OCSBadRequestException('Expiration time should be greater than 0 and less than or equal to ' . (60 * 60 * 24));\n\t\t}\n\n\t\tif (!($file instanceof File)) {\n\t\t\tthrow new OCSBadRequestException('Direct download only works for files');\n\t\t}\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Controller/DirectController.php#L45-L81","documentation":"Error \"Creating direct links is disabled\" thrown in nextcloud/server.","triggerScenarios":"Thrown at apps/dav/lib/Controller/DirectController.php:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}