I have been able to use the great answers at https://forum.backdropcms.org/forum/entity-metadata-wrappers-usage-questions for all my other fields, but am having problems with a file field.
In this case, what is the proper value to set it to? I am doing something like:
$wrapper->my_filefield = $my_value;
I have tried FID and an actual file object for $my_value, but it didn't like either one. This does work:
$wrapper->my_filefield = (array) $file;
Is this correct? Or is there a better way to do it?
OK, another workaround, but using wrappers. This works:
$wrapper->field_a_file = array( 'fid' => 1, 'display' => 1 );
The property "display" is required in Backdrop.