/**
  * {@inheritdoc}
  */
 public function processImageContent($entityType, $imageContent)
 {
     if (!$this->contentValidator->isValid($imageContent)) {
         throw new InputException(new Phrase('The image content is not valid.'));
     }
     $fileContent = @base64_decode($imageContent->getBase64EncodedData(), true);
     $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
     $fileName = substr(md5(rand()), 0, 7) . '.' . $imageContent->getName();
     $tmpDirectory->writeFile($fileName, $fileContent);
     $fileAttributes = ['tmp_name' => $tmpDirectory->getAbsolutePath() . $fileName, 'name' => $imageContent->getName()];
     try {
         $this->uploader->processFileAttributes($fileAttributes);
         $this->uploader->setFilesDispersion(true);
         $this->uploader->setFilenamesCaseSensitivity(false);
         $this->uploader->setAllowRenameFiles(true);
         $destinationFolder = $entityType;
         $this->uploader->save($this->mediaDirectory->getAbsolutePath($destinationFolder), $imageContent->getName());
     } catch (\Exception $e) {
         $this->logger->critical($e);
     }
     return $this->uploader->getUploadedFileName();
 }