Beispiel #1
0
 /**
  * Tears down this test case
  *
  * @return void
  */
 public function tearDown()
 {
     if (!$this->_config) {
         return;
     }
     // Delete the bucket here
     $s3 = new AmazonS3($this->_config->get(\ZendCloud\StorageService\Adapter\S3::AWS_ACCESS_KEY), $this->_config->get(\ZendCloud\StorageService\Adapter\S3::AWS_SECRET_KEY));
     $s3->removeBucket($this->_config->get(\ZendCloud\StorageService\Adapter\S3::BUCKET_NAME));
     parent::tearDown();
 }
Beispiel #2
0
 public function testThrottle()
 {
     $s3 = new S3();
     $throttleTime = 0.001;
     // seconds
     $limit = 5;
     $throttler = function () use($s3, $throttleTime) {
         return $s3->throttle('microtime', array(true), $throttleTime);
     };
     $times = array_map($throttler, range(0, $limit));
     $diffs = array_map(function ($a, $b) {
         return $a - $b;
     }, array_slice($times, 1, count($times)), array_slice($times, 0, count($times) - 1));
     array_map(array($this, 'assertGreaterThanOrEqual'), array_fill(0, $limit, $throttleTime), $diffs);
 }
Beispiel #3
0
 /**
  * Returns data array of stream variables
  *
  * @return array
  */
 public function stream_stat()
 {
     if (!$this->_objectName) {
         return false;
     }
     $stat = array();
     $stat['dev'] = 0;
     $stat['ino'] = 0;
     $stat['mode'] = 0777;
     $stat['nlink'] = 0;
     $stat['uid'] = 0;
     $stat['gid'] = 0;
     $stat['rdev'] = 0;
     $stat['size'] = 0;
     $stat['atime'] = 0;
     $stat['mtime'] = 0;
     $stat['ctime'] = 0;
     $stat['blksize'] = 0;
     $stat['blocks'] = 0;
     if (($slash = strchr($this->_objectName, '/')) === false || $slash == strlen($this->_objectName) - 1) {
         /* bucket */
         $stat['mode'] |= 040000;
     } else {
         $stat['mode'] |= 0100000;
     }
     $info = $this->_s3->getInfo($this->_objectName);
     if (!empty($info)) {
         $stat['size'] = $info['size'];
         $stat['atime'] = time();
         $stat['mtime'] = $info['mtime'];
     }
     return $stat;
 }
Beispiel #4
0
 /**
  * Get a key/value array of metadata for the given path.
  *
  * @param  string $path
  * @param  array $options
  * @return array
  */
 public function fetchMetadata($path, $options = array())
 {
     try {
         return $this->_s3->getInfo($this->_getFullPath($path, $options));
     } catch (\ZendService\Amazon\S3\Exception $e) {
         throw new Exception\RuntimeException('Error on fetch: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
 /**
  * Test invalid bucket name (label starting with dash)
  *
  * @return void
  */
 public function testBucketNameLabelDash()
 {
     $this->setExpectedException('\\ZendService\\Amazon\\S3\\Exception\\InvalidArgumentException');
     $this->amazon->_validBucketName('iam.aninvalid.-bucketname');
 }