/** * Constructor * * @param array|Zend\Config\Config $options * @return void */ public function __construct($options = array()) { if ($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } if (!is_array($options)) { throw new Exception\InvalidArgumentException('Invalid options provided'); } if (!isset($options[self::AWS_ACCESS_KEY]) || !isset($options[self::AWS_SECRET_KEY])) { throw new Exception\InvalidArgumentException('AWS keys not specified!'); } try { $this->_s3 = new AmazonS3($options[self::AWS_ACCESS_KEY], $options[self::AWS_SECRET_KEY]); } catch (Zend\Service\Amazon\S3\Exception $e) { throw new Exception\RuntimeException('Error on create: ' . $e->getMessage(), $e->getCode(), $e); } if (isset($options[self::HTTP_ADAPTER])) { $this->_s3->getHttpClient()->setAdapter($options[self::HTTP_ADAPTER]); } if (isset($options[self::BUCKET_NAME])) { $this->_defaultBucketName = $options[self::BUCKET_NAME]; } if (isset($options[self::BUCKET_AS_DOMAIN])) { $this->_defaultBucketAsDomain = $options[self::BUCKET_AS_DOMAIN]; } }