diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-13 17:40:52 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-04-26 10:35:37 +0200 |
commit | 6a385dd20bad8d0e6c7d923f77eea7b5f719fddd (patch) | |
tree | 54b6df64955bf2f092dfb1cb6d14d9241981e6a3 /apps/dav/lib | |
parent | 164d9988567ea46e88c6a968520a71b9b91315b8 (diff) | |
download | nextcloud-server-6a385dd20bad8d0e6c7d923f77eea7b5f719fddd.tar.gz nextcloud-server-6a385dd20bad8d0e6c7d923f77eea7b5f719fddd.zip |
Add directDownload support of storage
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Controller/DirectController.php | 27 | ||||
-rw-r--r-- | apps/dav/lib/Direct/DirectHome.php | 1 |
2 files changed, 16 insertions, 12 deletions
diff --git a/apps/dav/lib/Controller/DirectController.php b/apps/dav/lib/Controller/DirectController.php index c357771f3ff..3b8b0d1e2a6 100644 --- a/apps/dav/lib/Controller/DirectController.php +++ b/apps/dav/lib/Controller/DirectController.php @@ -87,23 +87,28 @@ class DirectController extends OCSController { } $file = array_shift($files); + $storage = $file->getStorage(); + $directDownload = $storage->getDirectDownload($file->getInternalPath()); - //TODO: try to get a url from the backend (like S3) + if (isset($directDownload['url'])) { + $url = $directDownload['url']; + } else { + // Fallback to our default implemenation + $direct = new Direct(); + $direct->setUserId($this->userId); + $direct->setFileId($fileId); + $token = $this->random->generate(60, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); + $direct->setToken($token); + $direct->setExpiration($this->timeFactory->getTime() + 60 * 60 * 8); - // Fallback to our default implemenation - $direct = new Direct(); - $direct->setUserId($this->userId); - $direct->setFileId($fileId); + $this->mapper->insert($direct); - $token = $this->random->generate(60, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS); - $direct->setToken($token); - $direct->setExpiration($this->timeFactory->getTime() + 60*60*8); - - $this->mapper->insert($direct); + $url = $this->urlGenerator->getAbsoluteURL('remote.php/direct/'.$token); + } return new DataResponse([ - 'url' => $this->urlGenerator->getAbsoluteURL('remote.php/direct/'.$token) + 'url' => $url, ]); } } diff --git a/apps/dav/lib/Direct/DirectHome.php b/apps/dav/lib/Direct/DirectHome.php index 9a3ee58224b..247cca7a3c9 100644 --- a/apps/dav/lib/Direct/DirectHome.php +++ b/apps/dav/lib/Direct/DirectHome.php @@ -26,7 +26,6 @@ namespace OCA\DAV\Direct; use OCA\DAV\Db\DirectMapper; use OCP\AppFramework\Db\DoesNotExistException; -use OCP\Files\File; use OCP\Files\IRootFolder; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\MethodNotAllowed; |