Search code examples
typo3extbasetypo3-6.2.xfal

How to retrieve meta data of a FAL Object in Extbase


In my extension I read Folders and Images. But in the result always the meta data from sys_file_metadata is missing and I found nothing how to load it.

The database entries are there so the file is indexed and everything seems to be ok. BE is working fine.

Here some code:

Controller-Action:

$storageId = 1;
$storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
$storage = $storageRepository->findByUid($storageId);
$singleFile = $storage->getFile('/user_upload/my_file.pdf');
$singleFile = true;
$this->view->assign('singleFile', $singleFile);

If I do a f:debug it showns me this:

Extbase Variable Dump

TYPO3\CMS\Core\Resource\Fileprototypeobject
   metaDataLoaded => FALSE
   metaDataProperties => array(empty)
   indexingInProgress => FALSE
   updatedProperties => array(empty)
   indexerService => NULL
   properties => array(15 items)
   storage => TYPO3\CMS\Core\Resource\ResourceStorageprototypeobject
   identifier => '/user_upload/my_file.pdf' (24 chars)
   name => 'my_file.pdf' (11 chars)
   deleted => FALSE

As you can see there is a field metaDataProperties and metaDataLoaded, so its not loaded.

Does anybody know how to load it?


Solution

  • You can try to use this in fluid

    {singleFile.properties.description}, {singleFile.properties.title} or {singleFile.properties.alternative}

    or this one to get all Properties

    $singleFile->_getMetaData()

    this can also be helpfull $singleFile->getProperty('description')