Classes/Utility/FAL.php
protected static function createIndex($fileName, $width, $height)
    {
        $relativePath = substr(PathUtility::dirname($fileName), strlen(PATH_site));
        $resourceFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
        $targetFolder = $resourceFactory->retrieveFileOrFolderObject($relativePath);
        $targetFilename = PathUtility::basename($fileName);

        $storageConfiguration = $targetFolder->getStorage()->getConfiguration();
        if (!isset($storageConfiguration['basePath'])) {
            // Probably a file found in uploads/ or similar
            return;
        }
        $basePath = rtrim($storageConfiguration['basePath'], '/') . '/';
        $basePath = GeneralUtility::getFileAbsFileName($basePath);
        $identifier = substr($fileName, strlen($basePath) - 1);

        // TODO: possibly create file with nearly no info and populate them with
        // a call to $file->getStorage()->getFileInfo($file) instead of using $driver
        /** @var \TYPO3\CMS\Core\Resource\Driver\AbstractDriver $driver */
        $driver = static::accessProtectedProperty($targetFolder->getStorage(), 'driver');
        $fileInfo = $driver->getFileInfoByIdentifier($identifier);
        $file = $resourceFactory->createFileObject($fileInfo);

        /** @var \TYPO3\CMS\Core\Resource\FileRepository $fileRepository */
        $fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
        $fileRepository->addToIndex($file);
    }
protected static function createIndex($fileName, $width, $height)
    {
        $relativePath = substr(PathUtility::dirname($fileName), strlen(PATH_site));
        $resourceFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
        $targetFolder = $resourceFactory->retrieveFileOrFolderObject($relativePath);
        $targetFilename = PathUtility::basename($fileName);

        $storageConfiguration = $targetFolder->getStorage()->getConfiguration();
        if (!isset($storageConfiguration['basePath'])) {
            // Probably a file found in uploads/ or similar
            return;
        }
        $basePath = rtrim($storageConfiguration['basePath'], '/') . '/';
        $basePath = GeneralUtility::getFileAbsFileName($basePath);
        $identifier = substr($fileName, strlen($basePath) - 1);

        // TODO: possibly create file with nearly no info and populate them with
        // a call to $file->getStorage()->getFileInfo($file) instead of using $driver
        /** @var \TYPO3\CMS\Core\Resource\Driver\AbstractDriver $driver */
        $driver = static::accessProtectedProperty($targetFolder->getStorage(), 'driver');
        $fileInfo = $driver->getFileInfoByIdentifier($identifier);
        $file = $resourceFactory->createFileObject($fileInfo);

        /** @var \TYPO3\CMS\Core\Resource\FileRepository $fileRepository */
        $fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
        $fileRepository->addToIndex($file);
    }
Creates the index entry for a given file.

@param string $fileName
@param integer $width
@param integer $height
@return void