/**
  * @param $photoHttpUrl
  * @return PhotoFile
  */
 private function downloadPhoto($photoHttpUrl)
 {
     $tmpLocation = $this->thumbGeneratorConfig->tempPath() . '/' . md5($photoHttpUrl);
     if (!file_exists($tmpLocation)) {
         $ch = curl_init($photoHttpUrl);
         $fp = fopen($tmpLocation, 'wb');
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_exec($ch);
         curl_close($ch);
         fclose($fp);
     }
     return new PhotoFile($tmpLocation);
 }
 /**
  * @param Photo $photo
  * @return PhotoFile | null
  */
 public function upload(Photo $photo)
 {
     $this->s3->putObject(['Bucket' => $this->config->bucket(), 'Key' => $this->getPhotoUri($photo->id(), $photo->slug(), $photo->photoFile()->format()), 'Body' => fopen($photo->photoFile()->filePath(), 'r'), 'ContentType' => $photo->photoFile()->mimeType(), 'ACL' => 'public-read']);
     rename($photo->photoFile()->filePath(), $this->thumbConfig->tempPath() . '/' . md5($photo->getPhotoHttpUrl()));
 }