userSession->getUser(); if ($user === null) { return new NotFoundResponse(); } $userFolder = $this->rootFolder->getUserFolder($user->getUID()); $nodes = $userFolder->getById($fileId); if (empty($nodes)) { return new NotFoundResponse(); } $file = array_shift($nodes); if (!$file instanceof File) { return new NotFoundResponse(); } $response = new DataDisplayResponse($file->getContent()); $response->addHeader('Content-Type', 'text/html; charset=utf-8'); return $response; } }