/**
  * Saves file which is available by @see ImageInstance::$imageUrl into @see $dir
  *
  * @param ImageInstance $imageInstance
  * @return int
  * @throws \Exception
  */
 public function save(ImageInstance $imageInstance)
 {
     if (!$this->checkDir()) {
         throw new \Exception('Wrong directory!');
     }
     $fileName = $imageInstance->getImageName();
     $fileFullName = $this->dir . DIRECTORY_SEPARATOR . $fileName;
     $imageUrl = $imageInstance->getImageUrl();
     return $this->createFile($fileFullName, $imageUrl);
 }