Esempio n. 1
0
 /**
  * Constructor
  * 
  * @param  array|Zend_Config $options 
  * @return void
  */
 public function __construct($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     if (!is_array($options)) {
         throw new Zend_Cloud_StorageService_Exception('Invalid options provided');
     }
     if (!isset($options[self::AWS_ACCESS_KEY]) || !isset($options[self::AWS_SECRET_KEY])) {
         throw new Zend_Cloud_StorageService_Exception('AWS keys not specified!');
     }
     try {
         $this->_s3 = new Zend_Service_Amazon_S3($options[self::AWS_ACCESS_KEY], $options[self::AWS_SECRET_KEY]);
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         throw new Zend_Cloud_StorageService_Exception('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];
     }
 }
Esempio n. 2
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     $this->_amazon = new Zend_Service_Amazon_S3(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY'));
     $this->_nosuchbucket = "nonexistingbucketnamewhichnobodyshoulduse";
     $this->_httpClientAdapterSocket = new Zend_Http_Client_Adapter_Socket();
     $this->_bucket = constant('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET');
     $this->_amazon->getHttpClient()->setAdapter($this->_httpClientAdapterSocket);
     // terms of use compliance: no more than one query per second
     sleep(1);
 }
Esempio n. 3
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     if (!constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ENABLED')) {
         $this->markTestSkipped('Zend_Service_Amazon online tests are not enabled');
     }
     $this->_amazon = new S3\S3(constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_ACCESSKEYID'), constant('TESTS_ZEND_SERVICE_AMAZON_ONLINE_SECRETKEY'));
     $this->_nosuchbucket = "nonexistingbucketnamewhichnobodyshoulduse";
     $this->_httpClientAdapterSocket = new \Zend\Http\Client\Adapter\Socket();
     $this->_bucket = constant('TESTS_ZEND_SERVICE_AMAZON_S3_BUCKET');
     $this->_amazon->getHttpClient()->setAdapter($this->_httpClientAdapterSocket);
 }
Esempio n. 4
0
 protected function _initApi()
 {
     if (!$this->_apiInitialized) {
         @ini_set('max_execution_time', self::TIMEOUT);
         @set_time_limit(self::TIMEOUT);
         if (!$this->_api) {
             $this->_api = new Garp_Service_Amazon_S3($this->_config['apikey'], $this->_config['secret']);
         }
         $this->_api->getHttpClient()->setConfig(array('timeout' => self::TIMEOUT, 'keepalive' => $this->_config['keepalive']));
         $this->_apiInitialized = true;
     }
 }