private function newUpload (BaseModel $model, $fieldName, UploadedFileInterface $file)
  {
    // Check is there are already files on this field.
    $filesRelation = $model->files ();
    /** @var Builder $filesQuery */
    $filesQuery = $filesRelation->ofField ($fieldName);
    /** @var File[] $files */
    $files = $filesQuery->get ();

    // Save new file
    $data = File::getFileData ($file->getClientFilename (), FileUtil::getUploadedFilePath ($file), $fieldName);
    /** @var File $fileModel */
    $fileModel = $filesRelation->create ($data);
    $this->repository->saveUploadedFile ($fileModel->path, $file);

    // Delete the previous files of this field, if any exists.
    // This is only performed AFTER the new file is successfully uploaded.
    foreach ($files as $file)
      $file->delete ();

    // If everything went ok, save the models.
    if (!in_array ($fieldName, $model::GALLERY_FIELDS))
      $model[$fieldName] = $fileModel->path;
    $model->save ();
  }