after_ingest_file

Hello,

I'm currently learning to develop for Omeka, and starting to get familiar with the hook system.

I must run a script to convert some some files after they are added to an item.

For this, I added this code to after_ingest_file :


$token = pathinfo($file['file']->filename, PATHINFO_FILENAME);
$rapport = pathinfo($file['file']->original_filename, PATHINFO_FILENAME);
$command = "/opt/www/pdf/pdffiletohtml.sh $token $rapport > /dev/null &";</p>
<p> _log("After ingest file : $command");
exec ($command, $y);

It's called correctly and the script does its job when executed from the command line.

But when it's called from Omeka, the converted files are not created.

I suspect it's because the file is not yet added to the filesystem when the hook fires.

Here's my question : where do I have to put this code for it to be executed at the right time ?

Thanks

I solved it outside Omeka by adding a wait loop top my script. It works well.

Conclusion : if you want to do something with an uploaded file, you'll have to make sure the file exists when your code executes, because Omeka doesn't do it, despite the hook being fired.

As it's slightly counterintuitive, thought I'd mention it for others.

Cheers