Browse Source
Merge pull request #11677 from nextcloud/feature/appdata_previews
Allow the creationg of previews of files stored in appdata
pull/11705/head
Morris Jobke
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
10 additions and
12 deletions
-
lib/private/Preview/GeneratorHelper.php
-
lib/private/PreviewManager.php
|
|
|
@ -26,6 +26,7 @@ use OC\Files\View; |
|
|
|
use OCP\Files\File; |
|
|
|
use OCP\Files\IRootFolder; |
|
|
|
use OCP\Files\SimpleFS\ISimpleFile; |
|
|
|
use OCP\IConfig; |
|
|
|
use OCP\IImage; |
|
|
|
use OCP\Image as OCPImage; |
|
|
|
use OCP\Preview\IProvider; |
|
|
|
@ -38,8 +39,12 @@ class GeneratorHelper { |
|
|
|
/** @var IRootFolder */ |
|
|
|
private $rootFolder; |
|
|
|
|
|
|
|
public function __construct(IRootFolder $rootFolder) { |
|
|
|
/** @var IConfig */ |
|
|
|
private $config; |
|
|
|
|
|
|
|
public function __construct(IRootFolder $rootFolder, IConfig $config) { |
|
|
|
$this->rootFolder = $rootFolder; |
|
|
|
$this->config = $config; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -60,16 +65,8 @@ class GeneratorHelper { |
|
|
|
* This is required to create the old view and path |
|
|
|
*/ |
|
|
|
private function getViewAndPath(File $file) { |
|
|
|
$absPath = ltrim($file->getPath(), '/'); |
|
|
|
$owner = explode('/', $absPath)[0]; |
|
|
|
|
|
|
|
$userFolder = $this->rootFolder->getUserFolder($owner)->getParent(); |
|
|
|
|
|
|
|
$nodes = $userFolder->getById($file->getId()); |
|
|
|
$file = $nodes[0]; |
|
|
|
|
|
|
|
$view = new View($userFolder->getPath()); |
|
|
|
$path = $userFolder->getRelativePath($file->getPath()); |
|
|
|
$view = new View($file->getParent()->getPath()); |
|
|
|
$path = $file->getName(); |
|
|
|
|
|
|
|
return [$view, $path]; |
|
|
|
} |
|
|
|
|
|
|
|
@ -195,7 +195,8 @@ class PreviewManager implements IPreview { |
|
|
|
$this, |
|
|
|
$this->appData, |
|
|
|
new GeneratorHelper( |
|
|
|
$this->rootFolder |
|
|
|
$this->rootFolder, |
|
|
|
$this->config |
|
|
|
), |
|
|
|
$this->eventDispatcher |
|
|
|
); |
|
|
|
|