/**
  * Store to FileStorage table.
  *
  * @param  object $docEntity Document entity
  * @param  string $field of the association
  * @param  array $fileData File data
  * @param  array $options for extra setup
  * @return object|bool Fresh created entity or false on unsuccesful attempts.
  */
 protected function _storeFileStorage($docEntity, $field, $fileData, $options = [])
 {
     $fieldsDefinitions = [];
     $fieldOption = [];
     $assocName = CsvMigrationsUtils::createAssociationName('Burzum/FileStorage.FileStorage', $field);
     $fileStorEnt = $this->_table->{$assocName}->newEntity($fileData);
     if (method_exists($this->_table, 'getFieldsDefinitions') && is_callable([$this->_table, 'getFieldsDefinitions'])) {
         $fieldsDefinitions = $this->_table->getFieldsDefinitions();
     }
     if (!empty($fieldsDefinitions)) {
         foreach ($fieldsDefinitions as $tableField => $definition) {
             if ($tableField == $field) {
                 $fieldOption = $definition;
                 break;
             }
         }
     }
     if (!empty($options['ajax'])) {
         //AJAX upload doesn't know anything about the entity
         //it relates to, as it's not saved yet
         $patchData = ['model' => $this->_table->table(), 'model_field' => $field];
     } else {
         $patchData = [$this->_fileStorageForeignKey => $docEntity->get('id'), 'model' => $this->_table->table(), 'model_field' => $field];
     }
     $fileStorEnt = $this->_table->{$assocName}->patchEntity($fileStorEnt, $patchData);
     if ($this->_table->{$assocName}->save($fileStorEnt)) {
         if (!empty($fieldOption) && $fieldOption['type'] == 'images') {
             $this->createThumbnails($fileStorEnt);
         }
         return $fileStorEnt;
     }
     return false;
 }