diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-04 19:41:04 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-03 14:00:32 +0100 |
commit | 958c1289b15f5bd877dd7ff3b7cf3540a0c5198a (patch) | |
tree | 94dea79e9d3fb96aa8528743960de15271d4c8b4 /core/ajax/preview.php | |
parent | b129adfb58eb98a37278dbd5a2f30b52c90cb4fc (diff) | |
download | nextcloud-server-958c1289b15f5bd877dd7ff3b7cf3540a0c5198a.tar.gz nextcloud-server-958c1289b15f5bd877dd7ff3b7cf3540a0c5198a.zip |
New preview generator
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'core/ajax/preview.php')
-rw-r--r-- | core/ajax/preview.php | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/core/ajax/preview.php b/core/ajax/preview.php index 6cfba6aef30..aac623b5ce6 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -49,19 +49,27 @@ if ($maxX === 0 || $maxY === 0) { exit; } -$info = \OC\Files\Filesystem::getFileInfo($file); +$folder = \OC::$server->getUserFolder(); -if (!$info instanceof OCP\Files\FileInfo || !$always && !\OC::$server->getPreviewManager()->isAvailable($info)) { +try { + $file = $folder->get($file); +} catch (\OCP\Files\NotFoundException $e) { + return \OC_Response::setStatus(404); +} + +if (!$file instanceof OCP\Files\File || !$always && !\OC::$server->getPreviewManager()->isAvailable($file)) { \OC_Response::setStatus(404); } else if (!$info->isReadable()) { \OC_Response::setStatus(403); } else { - $preview = new \OC\Preview(\OC_User::getUser(), 'files'); - $preview->setFile($file, $info); - $preview->setMaxX($maxX); - $preview->setMaxY($maxY); - $preview->setScalingUp($scalingUp); - $preview->setMode($mode); - $preview->setKeepAspect($keepAspect); - $preview->showPreview(); + $preview = new \OC\Preview2( + \OC::$server->getRootFolder(), + \OC::$server->getConfig(), + \OC::$server->getPreviewManager(), + $file + ); + $image = $preview->getPreview($maxX, $maxY, !$keepAspect, $mode); + + header('Content-Type: ' . $image->getMimeType()); + echo $image->getContent(); } |