[TYPO3-dam-devel] How to use DAM in an own extension

t.werdin t.werdin at web-vision.de
Thu Apr 12 16:27:00 CEST 2012


Dear developer Team,



I'm building an extbase extension. The FE-User should be able to upload images.

I move the images to the uploads/my_extension/ folder which is no problem.

Then I want to index the file with dam so I can save the uid of the dam record
in my model and save it to my table.



I try to index the file with:

$data = tx_dam::index_process($filename, array('doReindexing' => 99));



When I'm logged in as a BE-User this is no problem. But when I'm not logged in
in BE (such as a normal visitor and logged in FE-User) I get an fatal error.

This is because no BE_USER object is there. After reading through dam_frontend I
inserted:

if(empty($GLOBALS['BE_USER'])) {

    $GLOBALS['BE_USER'] = t3lib_div::makeInstance('t3lib_tsfeBeUserAuth');

    $GLOBALS['BE_USER']->start();

}



This helps to avoid the fatal error but the indexing is not working I get back
an empty array.



So I coppied another few code lines from dam_frontend:

$indexer = t3lib_div::makeInstance('tx_dam_indexing');

$indexer->init();

$indexer->setDefaultSetup();

$indexer->restoreSerializedSetup(array('doReindexing' => 99));

$indexer->initEnabledRules();

$indexer->collectMeta = true;

//$indexer->setDryRun(true);

$indexer->setPid(tx_dam_db::getPid());

$indexer->setRunType('man');

$data = $indexer->indexFile($filename);



This is similar to what index_process does.

But now I get an array which contains an failure message:

"Meta record could not be inserted: Attempt to modify table 'tx_dam' without
permission".



I'm working on this for over a weak now and our customer is waiting for his
extension.

Could you please tell me what is necessary to add a file to the index with dam?

Am I missing some parameters? What function do I have to user when a logged in
FE-User should be able to upload and index a file?



Please give me all mandatory settings etc so I can index a already uploaded file
and get back the uid.



Kind regards

Tim Werdin

--
web-vision GmbH
schlossstr. 527                41238 mönchengladbach
fon: +49 [0] 2166 . 94 04 54   fax: +49 [0] 2166 . 94 03 70

web design | content management | secure hosting


More information about the TYPO3-team-dam mailing list