/**
  * @param array $file_ids
  * @param string  $fieldname
  * @param IEntity $entity
  * @return void
  */
 public function upload(array $file_ids, $fieldname, IEntity $entity)
 {
     // assume that the file is connected via a has-one
     $relation = $entity->hasMethod($fieldname) ? $entity->{$fieldname}() : null;
     // try to create a file matching the relation
     if ($relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
         // has_many or many_many
         $relation->setByIDList($file_ids);
     } elseif ($entity->has_one($fieldname)) {
         // has_one
         $entity->{"{$fieldname}ID"} = $file_ids ? reset($file_ids) : 0;
     }
 }