diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-05-20 16:19:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-20 16:19:25 +0300 |
commit | bc8eaccbcd3d4fb8b244bb4a70c8accb57b91eec (patch) | |
tree | 70cbbcef9c02de8b36d2d433d2f290c4f33c3831 | |
parent | 18c5b105ea4fbf30c3a7b23b6ef0fd415440be95 (diff) | |
parent | 0326f064e831d615203afecdc13fcef1c0978453 (diff) |
Fix preview generation on object storage (#506)v3.3.4
Fix preview generation on object storage
-rw-r--r-- | lib/Preview/Office.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Preview/Office.php b/lib/Preview/Office.php index a8cf83dd..8e8ff2ea 100644 --- a/lib/Preview/Office.php +++ b/lib/Preview/Office.php @@ -63,7 +63,18 @@ abstract class Office extends Provider { * {@inheritDoc} */ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $stream = $fileview->fopen($path, 'r'); + $fileInfo = $fileview->getFileInfo($path); + if (!$fileInfo || $fileInfo->getSize() === 0) { + return false; + } + + $useTempFile = $fileInfo->isEncrypted() || !$fileInfo->getStorage()->isLocal(); + if ($useTempFile) { + $fileName = $fileview->toTmpFile($path); + $stream = fopen($fileName, 'r'); + } else { + $stream = $fileview->fopen($path, 'r'); + } $client = $this->clientService->newClient(); $options = ['timeout' => 10]; |