Get all files from all users for indexing


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!


Hi Fabian,
another way that I’m aware of is the following:

/** @var OCP\IDBConnection */
/** @var OCP\EventDispatcher\IEventDispatcher */
/** @var OCP\ILogger */
$users =  $this->userManager->callForAllUsers(function (IUser $user) use ($connection, $eventDispatcher, $logger): void {
  $scanner = new OC\Files\Utils\Scanner($user->getUID(), $connection, $eventDispatcher, $logger);
    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.



FYI there is an existing app for that

For completeness the link to the nextcloud app
app fulltextsearch_elasticsearch