当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Service_Amazon_S3::getInfo方法代码示例

本文整理汇总了PHP中Zend_Service_Amazon_S3::getInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Service_Amazon_S3::getInfo方法的具体用法?PHP Zend_Service_Amazon_S3::getInfo怎么用?PHP Zend_Service_Amazon_S3::getInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Service_Amazon_S3的用法示例。


在下文中一共展示了Zend_Service_Amazon_S3::getInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stream_stat

 /**
  * 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;
 }
开发者ID:fredcido,项目名称:simuweb,代码行数:38,代码来源:Stream.php

示例2: testBadNames

 public function testBadNames()
 {
     try {
         $this->_amazon->createBucket("This is a Very Bad Name");
         $this->fail("Expected exception not thrown");
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
     try {
         $this->_amazon->isBucketAvailable("This is a Very Bad Name");
         $this->fail("Expected exception not thrown");
     } catch (Zend_Uri_Exception $e) {
         $this->assertContains("not a valid HTTP host", $e->getMessage());
     }
     try {
         $this->_amazon->putObject("This is a Very Bad Name/And It Gets Worse", "testdata");
         $this->fail("Expected exception not thrown");
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
     try {
         $this->_amazon->getObject("This is a Very Bad Name/And It Gets Worse");
         $this->fail("Expected exception not thrown");
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
     try {
         $this->_amazon->getInfo("This is a Very Bad Name/And It Gets Worse");
         $this->fail("Expected exception not thrown");
     } catch (Zend_Service_Amazon_S3_Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:33,代码来源:OnlineTest.php

示例3: stream_stat

 /**
  * 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'] = 0;
     $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;
     $info = $this->_s3->getInfo($this->_objectName);
     if (!empty($info)) {
         $stat['size'] = $info['size'];
         $stat['atime'] = time();
         $stat['mtime'] = $info['mtime'];
     }
     return $stat;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:32,代码来源:Stream.php

示例4: testGetInfoWithBadName

 public function testGetInfoWithBadName()
 {
     $this->setExpectedException(
         'Zend\Service\Amazon\Sqs\Exception\InvalidArgumentException',
         'Bucket name "This is a Very Bad Name" contains invalid characters');
     $this->_amazon->getInfo("This is a Very Bad Name/And It Gets Worse");
 }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:7,代码来源:OnlineTest.php

示例5: fetchMetadata

 /**
  * 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 (Zend_Service_Amazon_S3_Exception $e) {
         throw new Zend_Cloud_StorageService_Exception('Error on fetch: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }
开发者ID:laiello,项目名称:vinhloi,代码行数:15,代码来源:S3.php

示例6: getTimestamp

 /**
  * Returns last modified time of file, as a Unix timestamp.
  *
  * @param string $filename
  * @return string
  */
 public function getTimestamp($filename)
 {
     $this->_initApi();
     $info = $this->_api->getInfo($this->_config['bucket'] . $this->_getUri($filename));
     if (array_key_exists('mtime', $info)) {
         return $info['mtime'];
     }
     throw new Exception("Could not retrieve timestamp of {$filename}.");
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:15,代码来源:S3.php

示例7: testBadNames

 public function testBadNames()
 {
     try {
         $this->_amazon->createBucket("This is a Very Bad Name");
         $this->fail("Expected exception not thrown");
     } catch (S3\Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
     try {
         $this->_amazon->isBucketAvailable("This is a Very Bad Name");
         $this->fail("Expected exception not thrown");
     } catch (\Zend\HTTP\Client\Adapter\Exception $e) {
         $this->assertContains("Unable to Connect to", $e->getMessage());
         //@todo check why \Http\Client exception is thrown instead of \Zend\Uri\Exception
     } catch (\Zend\URI\Exception $e) {
         $this->assertContains("not a valid HTTP host", $e->getMessage());
     }
     try {
         $this->_amazon->putObject("This is a Very Bad Name/And It Gets Worse", "testdata");
         $this->fail("Expected exception not thrown");
     } catch (S3\Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
     try {
         $this->_amazon->getObject("This is a Very Bad Name/And It Gets Worse");
         $this->fail("Expected exception not thrown");
     } catch (S3\Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
     try {
         $this->_amazon->getInfo("This is a Very Bad Name/And It Gets Worse");
         $this->fail("Expected exception not thrown");
     } catch (S3\Exception $e) {
         $this->assertContains("contains invalid characters", $e->getMessage());
     }
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:36,代码来源:OnlineTest.php

示例8: testGetInfoWithBadName

 public function testGetInfoWithBadName()
 {
     $this->setExpectedException('ZendService\\Amazon\\S3\\Exception\\InvalidArgumentException', 'Bucket name "VERY.BAD.NAME" contains invalid characters');
     $this->_amazon->getInfo("VERY.BAD.NAME/And It Gets Worse");
 }
开发者ID:tillk,项目名称:vufind,代码行数:5,代码来源:OnlineTest.php

示例9: addFile

 public function addFile($fileInfo, $userInfo, $privacy = false, $details = false)
 {
     $config = self::$_registry->get("config");
     $s3 = new Zend_Service_Amazon_S3($config['services']['S3']['key'], $config['services']['S3']['secret']);
     $filenameFilter = new Ml_Filter_FilenameRobot();
     $filenameValidator = new Ml_Validate_Filename();
     if (isset($details['title']) && !empty($details['title'])) {
         $title = $details['title'];
     } else {
         $title = mb_substr(trim($fileInfo['name']), 0, 100);
         /* try to use a good initial title for the file */
         $titleNameposition = mb_strrpos($title, ".");
         $titleSize = mb_strlen($title);
         if ($titleSize > 5 && $titleSize - $titleNameposition <= 5) {
             $tryTitle = mb_substr($title, 0, $titleNameposition);
             if (!empty($tryTitle) && strrpos($tryTitle, ".") < mb_strlen($tryTitle) - 4) {
                 $title = $tryTitle;
             }
         }
     }
     //get the max value of mt_getrandmax() or the max value of the unsigned int type
     $maxRand = mt_getrandmax() < 4294967295.0 ? mt_getrandmax() : 4294967295.0;
     $secret = mt_rand(0, $maxRand);
     $downloadSecret = mt_rand(0, $maxRand);
     $filename = $filenameFilter->filter($fileInfo['name']);
     if (!$filenameValidator->isValid($filename)) {
         $extension = $filenameFilter->filter(strchr($filename, '.'));
         if ($filenameValidator->isValid($extension)) {
             $filename = mt_rand() . $extension;
         } else {
             $filename = mt_rand();
         }
     }
     $this->_dbAdapter->beginTransaction();
     try {
         $this->_dbAdapter->insert("upload_history", array("byUid" => $userInfo['id'], "fileSize" => $fileInfo['size'], "filename" => $fileInfo['name']));
         $uploadId = $this->_dbAdapter->lastInsertId("upload_history");
         if (!$uploadId) {
             throw new Exception("Can not create upload ID.");
         }
         $objectKey = $userInfo['alias'] . "/" . $uploadId . "-" . $downloadSecret . "/" . $filename;
         $put = $s3->putFile($fileInfo['tmp_name'], $config['services']['S3']['sharesBucket'] . "/" . $objectKey, array(Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ, "Content-Type" => Zend_Service_Amazon_S3::getMimeType($objectKey), 'Content-Disposition' => 'attachment;', "x-amz-meta-id" => $uploadId, "x-amz-meta-uid" => $userInfo['id'], "x-amz-meta-username" => $userInfo['alias']));
         if (!$put) {
             throw new Exception("Could not upload to storage service.");
         }
         $getInfo = $s3->getInfo($objectKey);
         //If for error we can't retrieve the md5 from the s3 server...
         if (!$getInfo) {
             $md5 = md5_file($fileInfo['tmp_name']);
         } else {
             $md5 = $getInfo['etag'];
         }
         if (!isset($details['short'])) {
             $details['short'] = '';
         }
         if (!isset($details['description'])) {
             $details['description'] = '';
         }
         $this->_dbTable->insert(array("id" => $uploadId, "byUid" => $userInfo['id'], "secret" => $secret, "download_secret" => $downloadSecret, "privacy" => $privacy, "title" => $title, "filename" => $filename, "short" => $details['short'], "description" => $details['description'], "type" => mb_substr($fileInfo['type'], 0, 50), "fileSize" => $fileInfo['size'], "md5" => $md5));
         if (!$this->_dbAdapter->lastInsertId()) {
             throw new Exception("Could not create insert for new file.");
         }
         $this->_dbAdapter->commit();
         return $uploadId;
     } catch (Exception $e) {
         $this->_dbAdapter->rollBack();
         throw $e;
     }
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:69,代码来源:Share.php


注:本文中的Zend_Service_Amazon_S3::getInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。