userFolder = $iRootFolder->getUserFolder($userId); $this->file = $this->userFolder->get($path); $this->mapper = $mapper; $this->random = $random; $this->timeFactory = $timeFactory; $this->userId = $userId; $this->urlGenerator = $urlGenerator; } public function generateUrl() { $direct = new Direct(); $direct->setUserId($this->userId); $direct->setFileId($this->file->getId()); $token = $this->random->generate(60, ISecureRandom::CHAR_ALPHANUMERIC); $direct->setToken($token); $direct->setExpiration($this->timeFactory->getTime() + (60 * 60 * 8)); $this->mapper->insert($direct); $url = $this->urlGenerator->getAbsoluteURL('remote.php/direct/' . $token); return $url; } public function getUrl(): string { return $this->url; } public function getFilename(): string { return $this->file->getName(); } public function isValid(): bool { return !empty($this->file->getContent()); } }