How do I set a product image? When creating a product node for Ubercart, how do I set the product image?

I am using the following code to create a product node. 

$node = new stdClass();

$node-&gt;name = "Title";
$node-&gt;title = $node-&gt;name;
$node-&gt;body = "Lorem Ipsum"; 
$node-&gt;type = "configurator_product"; //my own product class
$node-&gt;created = time();
$node-&gt; changed = $node-&gt;created;
$node-&gt;promote = 0;
$node-&gt;sticky = 0;
$node-&gt;format = 2;
$node-&gt;status = 1;
$node-&gt;language = "en";
$node-&gt;default_qty = 1;
$node-&gt;sell_price = 55.00;
$node-&gt;shippable = 1;


The product node has a field_image_cache field which expects a file (extensions: png, gif, jpg, jpeg). I tried to set this field. 

$node-&gt;field_image_cache = "Path/to/module/Images/image1.jpeg";
// Results in Fatal error: Cannot unset string offsets in 
// path/to/modules/cck/content.module on line 1248

$node-&gt;field_image_cache[0]['value'] = "Path/to/module/Images/image1.jpeg";
// No errors, but when viewing the product in store administration there is no image


What is the correct way to set an image for a product?
$img_file = file_get_contents("Path/to/module/Images/image1.jpeg");
  $img_file = file_save_data($img_file, file_directory_path() .'/path2imagefield_folder/image1.jpeg', FILE_EXISTS_RENAME);
  $node-&gt;field_image_cache = array(
    array(
      'fid' =&gt; 'upload',
      'title' =&gt; basename($img_file),
      'filename' =&gt; basename($img_file),
      'filepath' =&gt; $img_file,
      'filesize' =&gt; filesize($img_file),
    ),
  );