PubPageController.php 749 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace OCA\Raw\Controller;
  3. use OCP\IRequest;
  4. use OCP\Share\IManager;
  5. use OCP\AppFramework\Controller;
  6. use OCP\Files\Folder;
  7. class PubPageController extends Controller {
  8. use RawResponse;
  9. private $manager;
  10. public function __construct(
  11. $AppName,
  12. IRequest $request,
  13. IManager $shareManager
  14. ) {
  15. parent::__construct($AppName, $request);
  16. $this->manager = $shareManager;
  17. }
  18. /**
  19. * @PublicPage
  20. * @NoAdminRequired
  21. * @NoCSRFRequired
  22. */
  23. public function getByToken($token) {
  24. $share = $this->manager->getShareByToken($token);
  25. $node = $share->getNode();
  26. // if ($node->getType() === 'dir') { TODO }
  27. $content = $node->getContent();
  28. $mimetype = $node->getMimeType();
  29. $this->returnRawResponse($content, $mimetype);
  30. }
  31. }