fabi_s
August 9, 2021, 7:56am
1
Hello!
Is it possible to get all files from all users and get the fileinfo for those files as well?
I want to iterate over the files and send them to an Elasticsearch Index.
So far i tried
$path = $this->view->getPath($file);
$this->logger->info("path: " . $path);
$fileInfo = $this->view->getFileInfo($path);
but with these functions i can only access my own files.
Is it even possible to do this?
Or is there a better way to index all the files?
Thanks a lot!
Fabian
Hi Fabian,
another way that Iām aware of is the following:
/** @var OCP\IDBConnection */
$connection;
/** @var OCP\EventDispatcher\IEventDispatcher */
$eventDispatcher;
/** @var OCP\ILogger */
$logger;
$users = $this->userManager->callForAllUsers(function (IUser $user) use ($connection, $eventDispatcher, $logger): void {
$scanner = new OC\Files\Utils\Scanner($user->getUID(), $connection, $eventDispatcher, $logger);
$scanner->listen(
'\OC\Files\Utils\Scanner',
'postScanFile',
function ($path) use ($logger) {
$logger->info("path: " . $path);
}
);
});
But Iām not sure if this is the best way.
This way has also the downside that it does not show files that have been shared.
Regards
Christian
For completeness the link to the nextcloud app
app fulltextsearch_elasticsearch