file_usage_add: custom type for my module I have a custom calendar module I've created. When a user creates an event they have the ability to attach a thumbnail image to it. I'm trying to make it use the managed_file type. In the documentation it appears I need to use file_usage_add to keep it from throwing an error. The problem is I'm not sure what to put in the 'type' and 'id' parameters. The documentation lists these required parameters:


$file: A file object. 
$module: The name of the module using the file.
$type: The type of the object that contains the referenced file.
$id: The unique, numeric ID of the object containing the referenced file.


$file and $module are easy. However, this module doesn't create a node or anything else. I have my own table structure for this information. Is there a way to define my table that events get stored in as a 'type' and pass that with the unique id from that table?
Yes, type just needs to be something unique within your module's types of file usage. The value of the string itself is arbitrary.

So if you have a module which stores pictures of cats and dogs, and you want to address those two different types of usage separately, you might use (contrived examples obviously):

$cat = MYMODULE_load_cat('whiskers');
file_usage_add($file, 'MYMODULE', 'cat_pictures', $cat-&gt;id);

$dog = MYMODULE_load_dog('fido');
file_usage_add($file, 'MYMODULE', 'dog_pictures', $dog-&gt;id);


But the type for those could just as easily be cat_foo and dog_foo, all that matters is that you (the module developer) know what they are, so they can be used appropriately with file_usage_delete().