diff options
author | Robin Appelman <robin@icewind.nl> | 2019-06-04 15:25:25 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2019-06-17 14:09:09 +0200 |
commit | 615061437422499025e038483504d4ef2004c8e1 (patch) | |
tree | bd8752decea5d8c10fea43bdcdd92c38c26ebf30 /lib/private/Preview/Office.php | |
parent | f6ad353c7c1176bcaa167051c9f3e118e69f7a20 (diff) | |
download | nextcloud-server-615061437422499025e038483504d4ef2004c8e1.tar.gz nextcloud-server-615061437422499025e038483504d4ef2004c8e1.zip |
Add new Provider interface for preview providers
the main difference is passing the `File` object to the provider
instead of a `View` + path
Old providers will still continue to work as before
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Preview/Office.php')
-rw-r--r-- | lib/private/Preview/Office.php | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/private/Preview/Office.php b/lib/private/Preview/Office.php index 4a2aa7f4953..f51023c5a83 100644 --- a/lib/private/Preview/Office.php +++ b/lib/private/Preview/Office.php @@ -25,21 +25,23 @@ */ namespace OC\Preview; +use OCP\IImage; use OCP\ILogger; +use OCP\Files\File; -abstract class Office extends Provider { +abstract class Office extends ProviderV2 { private $cmd; /** * {@inheritDoc} */ - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { $this->initCmd(); if (is_null($this->cmd)) { - return false; + return null; } - $absPath = $fileview->toTmpFile($path); + $absPath = $this->getLocalFile($file); $tmpDir = \OC::$server->getTempManager()->getTempBaseDir(); @@ -59,19 +61,19 @@ abstract class Office extends Provider { $png = new \imagick($pngPreview . '[0]'); $png->setImageFormat('jpg'); } catch (\Exception $e) { - unlink($absPath); + $this->cleanTmpFiles(); unlink($pngPreview); \OC::$server->getLogger()->logException($e, [ 'level' => ILogger::ERROR, 'app' => 'core', ]); - return false; + return null; } $image = new \OC_Image(); $image->loadFromData($png); - unlink($absPath); + $this->cleanTmpFiles(); unlink($pngPreview); if ($image->valid()) { @@ -79,7 +81,7 @@ abstract class Office extends Provider { return $image; } - return false; + return null; } |