Create/upload file from logic_hook

Hi All,
i’m completely new to SuiteCRM so please excuse any “ridiculous” questions :slight_smile:

I got a hang of logic_hooks and can create new objects from it in following fashion
( create new Note when saving customer )

<?php if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); class updateNameHook { function main($bean, $event, $arguments) { $beantwo = BeanFactory::newBean('Notes'); $beantwo->name=$bean->billing_address_street; $beantwo->description='123 this is description'; $beantwo->save(); } } ?>

Now - how can i create a custom “file” object this way,
i need to call external (CLI) app to create PDFs and would like to upload it and link it to this object (relations are defined already in module builder).
Do i have to create the object, copy the file into folder and link it all “manually” through my own logic or is there some mechanics in place?

Thanks very much in advance.

V.K.