diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-18 10:36:57 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-03 14:00:33 +0100 |
commit | 55af6b45f72e0717d7b6f07b69bc0f12f4fb4cd9 (patch) | |
tree | 94990fdc1391dc5e2f558522bbbac377daa2fd3e /core/Controller/PreviewController.php | |
parent | 87855aa97b0d90f8036ec40174ac1a3dcbd463e8 (diff) | |
download | nextcloud-server-55af6b45f72e0717d7b6f07b69bc0f12f4fb4cd9.tar.gz nextcloud-server-55af6b45f72e0717d7b6f07b69bc0f12f4fb4cd9.zip |
More tests
* PreviewController test
* PublicPreview test
* Versions Preview test
* Trash Preview test
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'core/Controller/PreviewController.php')
-rw-r--r-- | core/Controller/PreviewController.php | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/core/Controller/PreviewController.php b/core/Controller/PreviewController.php index f54681a856b..3a245374e96 100644 --- a/core/Controller/PreviewController.php +++ b/core/Controller/PreviewController.php @@ -23,11 +23,11 @@ namespace OC\Core\Controller; -use OC\DatabaseException; use OCP\AppFramework\Controller; use OCP\Files\File; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\FileDisplayResponse; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\IPreview; @@ -86,11 +86,7 @@ class PreviewController extends Controller { $forceIcon = true, $mode = 'fill') { - if ($file === '') { - return new DataResponse([], Http::STATUS_BAD_REQUEST); - } - - if ($x === 0 || $y === 0) { + if ($file === '' || $x === 0 || $y === 0) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -109,9 +105,10 @@ class PreviewController extends Controller { try { $f = $this->preview->getPreview($file, $x, $y, !$a, $mode); + return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); } catch (NotFoundException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } - return new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); + } } |