/**
  * @return \Magento\Framework\Controller\Result\Raw
  */
 public function execute()
 {
     try {
         $remoteFileUrl = $this->getRequest()->getParam('remote_image');
         $originalFileName = $this->parseOriginalFileName($remoteFileUrl);
         $localFileName = $this->localFileName($originalFileName);
         $localTmpFileName = $this->generateTmpFileName($localFileName);
         $localFileMediaPath = $this->appendFileSystemPath($localTmpFileName);
         $localUniqueFileMediaPath = $this->appendNewFileName($localFileMediaPath);
         $this->retrieveRemoteImage($remoteFileUrl, $localUniqueFileMediaPath);
         $localFileFullPath = $this->appendAbsoluteFileSystemPath($localUniqueFileMediaPath);
         $this->imageAdapter->validateUploadFile($localFileFullPath);
         $result = $this->appendResultSaveRemoteImage($localUniqueFileMediaPath);
     } catch (\Exception $e) {
         $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
     }
     /** @var \Magento\Framework\Controller\Result\Raw $response */
     $response = $this->resultRawFactory->create();
     $response->setHeader('Content-type', 'text/plain');
     $response->setContents(json_encode($result));
     return $response;
 }