Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2021-11-02 19:28:19 +0300
committerJulien Veyssier <eneiluj@posteo.net>2022-01-03 12:27:35 +0300
commit1b330966523f056727e400c5ed6dc14d405b6423 (patch)
tree5d0bf50d2eb28251c9144c4993387fae1ef0ba94 /lib/Service
parentb1fe3651834038414274addc86bb2d18094eafdc (diff)
serve image previews
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/ImageService.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Service/ImageService.php b/lib/Service/ImageService.php
index b9d2bcd17..309963b92 100644
--- a/lib/Service/ImageService.php
+++ b/lib/Service/ImageService.php
@@ -32,6 +32,8 @@ use OCP\Constants;
use OCP\Files\Folder;
use OCP\Files\File;
use OCP\Files\NotFoundException;
+use OCP\Files\SimpleFS\ISimpleFile;
+use OCP\IPreview;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IShare;
use Throwable;
@@ -64,15 +66,21 @@ class ImageService {
* @var LoggerInterface
*/
private $logger;
+ /**
+ * @var IPreview
+ */
+ private $previewManager;
public function __construct(IRootFolder $rootFolder,
LoggerInterface $logger,
ShareManager $shareManager,
+ IPreview $previewManager,
IClientService $clientService) {
$this->rootFolder = $rootFolder;
$this->shareManager = $shareManager;
$this->clientService = $clientService;
$this->logger = $logger;
+ $this->previewManager = $previewManager;
}
/**
@@ -88,7 +96,7 @@ class ImageService {
* @throws \OCP\Lock\LockedException
* @throws \OC\User\NoUserException
*/
- public function getImage(int $textFileId, string $imageFileName, string $userId): ?File {
+ public function getImage(int $textFileId, string $imageFileName, string $userId): ?ISimpleFile {
$textFile = $this->getTextFile($textFileId, $userId);
$attachmentFolder = $this->getOrCreateAttachmentDirectoryForFile($textFile);
if ($attachmentFolder !== null) {
@@ -98,7 +106,8 @@ class ImageService {
return null;
}
if ($imageFile instanceof File) {
- return $imageFile;
+// return $imageFile;
+ return $this->previewManager->getPreview($imageFile, 1024, 1024);
}
}
return null;
@@ -117,7 +126,7 @@ class ImageService {
* @throws \OCP\Lock\LockedException
* @throws \OC\User\NoUserException
*/
- public function getImagePublic(int $textFileId, string $imageFileName, string $shareToken): ?File {
+ public function getImagePublic(int $textFileId, string $imageFileName, string $shareToken): ?ISimpleFile {
$textFile = $this->getTextFilePublic($textFileId, $shareToken);
$attachmentFolder = $this->getOrCreateAttachmentDirectoryForFile($textFile);
if ($attachmentFolder !== null) {
@@ -127,7 +136,8 @@ class ImageService {
return null;
}
if ($imageFile instanceof File) {
- return $imageFile;
+// return $imageFile;
+ return $this->previewManager->getPreview($imageFile, 1024, 1024);
}
}
return null;