I need to save and edit entities via services like {user, nodes, products ...etc}
the problem comes with images posted form mobile apps encoded base64.
I saved the file and stored the object in session to be used in hook_services_request_postprocess_alter to be added to the entity saved by loading it again and assign the value to the field
// in preprocess
$_SESSION['file'] = file_save_data(base64_decode($args[0]['image']),'public://test.png');
// in postprocess
$product = entity_load('commerce_product', array($result->product_id));
$wrapper = entity_metadata_wrapper('commerce_product', $product);
//$wrapper->field_field_user_avatar->file->set($_SESSION['file']);
//$wrapper->field_field_user_avatar['und'][0]['value']=(array)$_SESSION['file'];
//$wrapper->save();
entity_save('commerce_product', $product);
what missing here I have tried many answers either adding the file object to the field when creating the field nor entity saving
fid
instead ofvalue
and set it equal to the file id.