manager = $shareManager; } /** * @PublicPage * @NoAdminRequired * @NoCSRFRequired */ public function getByToken($token) { $share = $this->manager->getShareByToken($token); $node = $share->getNode(); if ($node->getType() === 'dir') { // Is there some reasonable thing to return for a directory? An html index? A tarball? throw new Exception("Requested share is a directory, not a file."); } $content = $node->getContent(); $mimetype = $node->getMimeType(); $this->returnRawResponse($content, $mimetype); } /** * @PublicPage * @NoAdminRequired * @NoCSRFRequired */ public function getByTokenAndPath($token, $path) { $share = $this->manager->getShareByToken($token); $dirNode = $share->getNode(); if ($dirNode->getType() !== 'dir') { throw new Exception("Received a sub-path for a share that is not a directory"); } $fileNode = $dirNode->get($path); if ($fileNode->getType() === 'dir') { // Is there some reasonable thing to return for a directory? An html index? A tarball? throw new Exception("Requested share is a directory, not a file."); } $content = $fileNode->getContent(); $mimetype = $fileNode->getMimeType(); $this->returnRawResponse($content, $mimetype); } }