Exemplo n.º 1
0
 /**
  * Upload file to AWS
  * 
  * @param $filePath
  */
 public function uploadToAWS($filePath)
 {
     $s3 = $this->_getS3Object();
     $file = $s3->inputFile($filePath);
     $headers = craft()->imager->getSetting('awsRequestHeaders');
     if (!isset($headers['Cache-Control'])) {
         $headers['Cache-Control'] = 'max-age=' . craft()->imager->getSetting('awsCacheDuration') . ', must-revalidate';
     }
     if (!$s3->putObject($file, craft()->imager->getSetting('awsBucket'), ImagerService::fixSlashes(craft()->imager->getSetting('awsFolder') . '/' . str_replace(craft()->imager->getSetting('imagerSystemPath'), '', $filePath), true, true), \S3::ACL_PUBLIC_READ, array(), $headers, $this->_getAWSStorageClass())) {
         ImagerPlugin::log("Upload to AWS failed for {$filePath} in ImagerService", LogLevel::Error);
     }
 }
 /**
  * Get paths for a local file that's in the imager path
  *
  * @param $image
  */
 private function _getPathsForLocaleFile($image)
 {
     $pathParts = pathinfo($image);
     $this->sourcePath = $_SERVER['DOCUMENT_ROOT'] . $pathParts['dirname'] . '/';
     $this->targetPath = ImagerService::fixSlashes(craft()->imager->getSetting('imagerSystemPath') . $pathParts['dirname'] . '/');
     $this->targetUrl = craft()->imager->getSetting('imagerUrl') . ImagerService::fixSlashes($pathParts['dirname'] . '/', true);
     $this->sourceFilename = $this->targetFilename = $pathParts['basename'];
 }
 /**
  * Converts a rgb color value to hex
  * 
  * @param array $color
  * @return string
  */
 public function rgb2hex($color)
 {
     return ImagerService::rgb2hex($color);
 }