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


PHP S3Request类代码示例

本文整理汇总了PHP中S3Request的典型用法代码示例。如果您正苦于以下问题:PHP S3Request类的具体用法?PHP S3Request怎么用?PHP S3Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getBucketLocation

 public static function getBucketLocation($bucket)
 {
     $rest = new S3Request('GET', $bucket, '');
     $rest->setParameter('location', null);
     $rest = $rest->getResponse();
     if ($rest->error !== false || $rest->code !== 200) {
         throw new Exception(sprintf("S3::getBucketLocation(%s): [%s] %s", $bucket, $rest->code, 'Unexpected HTTP status'));
     }
     return isset($rest->body[0]) && (string) $rest->body[0] !== '' ? (string) $rest->body[0] : 'US';
 }
开发者ID:comdan66,项目名称:TaipeiTowns,代码行数:10,代码来源:S3.php

示例2: deleteDistribution

 /**
  * Delete a CloudFront distribution
  *
  * @param array $dist Distribution array info identical to output of getDistribution()
  * @return boolean
  */
 public static function deleteDistribution($dist)
 {
     if (!extension_loaded('openssl')) {
         self::__triggerError(sprintf("S3::deleteDistribution({$dist['id']}): %s", "CloudFront functionality requires SSL"), __FILE__, __LINE__);
         return false;
     }
     $useSSL = self::$useSSL;
     self::$useSSL = true;
     // CloudFront requires SSL
     $rest = new S3Request('DELETE', '', '2008-06-30/distribution/' . $dist['id'], 'cloudfront.amazonaws.com');
     $rest->setHeader('If-Match', $dist['hash']);
     $rest = self::__getCloudFrontResponse($rest);
     self::$useSSL = $useSSL;
     if ($rest->error === false && $rest->code !== 204) {
         $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->error !== false) {
         self::__triggerError(sprintf("S3::deleteDistribution({$dist['id']}): [%s] %s", $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
         return false;
     }
     return true;
 }
开发者ID:chiunti,项目名称:amazon-s3-php-class,代码行数:28,代码来源:S3.php

示例3: invalidate

 /**
  * Invalidates files in a CloudFront distribution
  *
  * @param string $distributionId Distribution ID from listDistributions()
  * @param string $path Path to file to be invalidated
  * @return boolean
  */
 public static function invalidate($distributionId, $path)
 {
     self::$useSSL = true;
     // CloudFront requires SSL
     $rest = new S3Request('POST', '', '2010-08-01/distribution/' . $distributionId . '/invalidation', 'cloudfront.amazonaws.com');
     $rest->data = self::__getCloudFrontInvalidationBatchXML($path);
     $rest->size = strlen($rest->data);
     $rest->setHeader('Content-Type', 'text/xml');
     $rest = self::__getCloudFrontResponse($rest);
     if ($rest->error === false && $rest->code !== 201) {
         $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->error !== false) {
         trigger_error(sprintf("S3::invalidate(): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     }
     return true;
 }
开发者ID:julesbravo,项目名称:s3-php5-curl,代码行数:25,代码来源:S3.php

示例4: deleteDistribution

 /**
  * Delete a CloudFront distribution
  *
  * @param array $dist Distribution array info identical to output of getDistribution()
  * @return boolean
  */
 public static function deleteDistribution($dist)
 {
     self::$useSSL = true;
     // CloudFront requires SSL
     $rest = new S3Request('DELETE', '', '2008-06-30/distribution/' . $dist['id'], 'cloudfront.amazonaws.com');
     $rest->setHeader('If-Match', $dist['hash']);
     $rest = self::__getCloudFrontResponse($rest);
     if ($rest->error === false && $rest->code !== 204) {
         $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->error !== false) {
         trigger_error(sprintf("S3::deleteDistribution({$dist['id']}): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     }
     return true;
 }
开发者ID:rczamor,项目名称:Activ8,代码行数:22,代码来源:S3.php

示例5: createInvalidation

 /**
  * Creates invalidation bath
  *
  * @static
  * @param integer $distributionId
  * @param array $paths
  * @return array|bool
  */
 public static function createInvalidation($distributionId, $paths)
 {
     self::$use_ssl = true;
     // CloudFront requires SSL
     $rest = new S3Request('POST', '', '2010-11-01/distribution/' . $distributionId . '/invalidation', 'cloudfront.amazonaws.com');
     $rest->data = self::__getCloudFrontInvalidationBath($paths);
     $rest->size = strlen($rest->data);
     $rest->setHeader('Content-Type', 'application/xml');
     $rest = self::__getCloudFrontResponse($rest);
     if ($rest->error === false && $rest->code !== 201) {
         $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->error !== false) {
         trigger_error(sprintf("S3::createInvalidation(%d, '%s'): [%s] %s", $distributionId, implode(', ', $paths), $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     } elseif ($rest->body instanceof SimpleXMLElement) {
         return self::__parseCloudFrontInvalidation($rest->body);
     }
     return false;
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:28,代码来源:S3.php

示例6: getObject

 /**
  * Get an object
  *
  * @param string $bucket Bucket name
  * @param string $uri Object URI
  * @param mixed &$saveTo Filename or resource to write to
  * @return mixed
  */
 public static function getObject($bucket = '', $uri = '', $saveTo = false)
 {
     $rest = new S3Request('GET', $bucket, $uri);
     if ($saveTo !== false) {
         if (is_resource($saveTo)) {
             $rest->fp =& $saveTo;
         } else {
             if (($rest->fp = @fopen($saveTo, 'wb')) == false) {
                 $rest->response->error = array('code' => 0, 'message' => 'Unable to open save file for writing: ' . $saveTo);
             }
         }
     }
     if ($rest->response->error === false) {
         $rest->getResponse();
     }
     if ($rest->response->error === false && $rest->response->code !== 200) {
         $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->response->error !== false) {
         trigger_error(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s", $rest->response->error['code'], $rest->response->error['message']), E_USER_WARNING);
         return false;
     }
     $rest->file = realpath($saveTo);
     return $rest->response;
 }
开发者ID:piqiu0304,项目名称:S3ForMe-PHP,代码行数:33,代码来源:S3.php

示例7: getAccessControlPolicy

 /**
  * Get object or bucket Access Control Policy
  *
  * Currently this will trigger an error if there is no ACL on an object (will fix soon)
  *
  * @param string $bucket Bucket name
  * @param string $uri Object URI
  * @return mixed | false
  */
 public static function getAccessControlPolicy($bucket, $uri = '')
 {
     $rest = new S3Request('GET', $bucket, $uri);
     $rest->setParameter('acl', null);
     $rest = $rest->getResponse();
     if ($rest->error === false && $rest->code !== 200) {
         $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->error !== false) {
         trigger_error(sprintf("S3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     }
     $acp = array();
     if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName)) {
         $acp['owner'] = array('id' => (string) $rest->body->Owner->ID, 'name' => (string) $rest->body->Owner->DisplayName);
     }
     if (isset($rest->body->AccessControlList)) {
         $acp['acl'] = array();
         foreach ($rest->body->AccessControlList->Grant as $grant) {
             foreach ($grant->Grantee as $grantee) {
                 if (isset($grantee->ID, $grantee->DisplayName)) {
                     // CanonicalUser
                     $acp['acl'][] = array('type' => 'CanonicalUser', 'id' => (string) $grantee->ID, 'name' => (string) $grantee->DisplayName, 'permission' => (string) $grant->Permission);
                 } elseif (isset($grantee->EmailAddress)) {
                     // AmazonCustomerByEmail
                     $acp['acl'][] = array('type' => 'AmazonCustomerByEmail', 'email' => (string) $grantee->EmailAddress, 'permission' => (string) $grant->Permission);
                 } elseif (isset($grantee->URI)) {
                     // Group
                     $acp['acl'][] = array('type' => 'Group', 'uri' => (string) $grantee->URI, 'permission' => (string) $grant->Permission);
                 } else {
                     continue;
                 }
             }
         }
     }
     return $acp;
 }
开发者ID:mustafakarali,项目名称:orchidframework,代码行数:46,代码来源:s3.php

示例8: copy

	/**
	* Copy an object
	*
	* @param string $bucket Source bucket name
	* @param string $uri Source object URI
	* @param string $bucket Destination bucket name
	* @param string $uri Destination object URI
	* @param constant $acl ACL constant
	* @return mixed | false
	*/
	public function copy($srcBucket, $srcUri, $bucket, $uri, $acl = StorageManager::ACL_PRIVATE) 
	{
		$rest = new S3Request($this->id,$this->secret,$this->useSSL,'PUT', $bucket, $uri);
		$rest->setAmzHeader('x-amz-acl', $acl);
		$rest->setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, $srcUri));
		$rest = $rest->getResponse();
	
		if ($rest->error === false && $rest->code !== 200)
			$rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
	
		if ($rest->error !== false) 
			throw new AWSException(sprintf("S3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']));
		
		return isset($rest->body->LastModified, $rest->body->ETag) ? array(
			'time' => strtotime((string)$rest->body->LastModified),
			'hash' => substr((string)$rest->body->ETag, 1, -1)
		) : false;
	}
开发者ID:nikels,项目名称:HeavyMetal,代码行数:28,代码来源:s3.php

示例9: amazon_upload_file

 private function amazon_upload_file($data)
 {
     $response =& $this->request->post['last'];
     $s3 =& $data['s3'];
     $buckets = $s3->listBuckets();
     $cssjs_browser_cache = 0;
     $images_browser_cache = 0;
     if (getNitroPersistence('BrowserCache.Enabled') && getNitroPersistence('BrowserCache.Headers.Pages.Expires')) {
         if (getNitroPersistence('BrowserCache.CSSJS.Period')) {
             switch (getNitroPersistence('BrowserCache.CSSJS.Period')) {
                 case '1 week':
                     $cssjs_browser_cache = 7 * 24 * 3600;
                     break;
                 case '1 month':
                     $cssjs_browser_cache = 30 * 24 * 3600;
                     break;
                 case '6 months':
                     $cssjs_browser_cache = 6 * 30 * 24 * 3600;
                     break;
                 case '1 year':
                     $cssjs_browser_cache = 365 * 24 * 3600;
                     break;
                 default:
                     $cssjs_browser_cache = 0;
             }
         }
         if (getNitroPersistence('BrowserCache.Images.Period')) {
             switch (getNitroPersistence('BrowserCache.Images.Period')) {
                 case '1 week':
                     $images_browser_cache = 7 * 24 * 3600;
                     break;
                 case '1 month':
                     $images_browser_cache = 30 * 24 * 3600;
                     break;
                 case '6 months':
                     $images_browser_cache = 6 * 30 * 24 * 3600;
                     break;
                 case '1 year':
                     $images_browser_cache = 365 * 24 * 3600;
                     break;
                 default:
                     $images_browser_cache = 0;
             }
         }
     }
     $source = $data['file']['realpath'];
     $destination = $data['file']['file'];
     $ext = strtolower(pathinfo($source, PATHINFO_EXTENSION));
     if (getNitroPersistence('CDNAmazon.SyncCSS') && in_array($ext, unserialize(NITRO_EXTENSIONS_CSS))) {
         $bucket = getNitroPersistence('CDNAmazon.CSSBucket');
         if (is_array($buckets) && in_array($bucket, $buckets)) {
             $compress = getNitroPersistence('Compress.CSS') && getNitroPersistence('Compress.CSSLevel') ? (int) getNitroPersistence('Compress.CSSLevel') : false;
             $cache_time = $cssjs_browser_cache;
         } else {
             throw new Exception('The CSS bucket does not exist. Please create it.');
         }
     }
     if (getNitroPersistence('CDNAmazon.SyncJavaScript') && in_array($ext, unserialize(NITRO_EXTENSIONS_JS))) {
         $bucket = getNitroPersistence('CDNAmazon.JavaScriptBucket');
         if (is_array($buckets) && in_array($bucket, $buckets)) {
             $compress = getNitroPersistence('Compress.JS') && getNitroPersistence('Compress.JSLevel') ? (int) getNitroPersistence('Compress.JSLevel') : false;
             $cache_time = $cssjs_browser_cache;
         } else {
             throw new Exception('The JS bucket does not exist. Please create it.');
         }
     }
     if (getNitroPersistence('CDNAmazon.SyncImages') && in_array($ext, unserialize(NITRO_EXTENSIONS_IMG))) {
         $bucket = getNitroPersistence('CDNAmazon.ImageBucket');
         if (is_array($buckets) && in_array($bucket, $buckets)) {
             $compress = false;
             $cache_time = $images_browser_cache;
         } else {
             throw new Exception('The images bucket does not exist. Please create it.');
         }
     }
     if (empty($bucket)) {
         return;
     }
     $req = new S3Request('HEAD', $bucket, $destination);
     $res = $req->getResponse();
     $to_upload = $res->code != 200 || $res->code == 200 && ((!empty($compress) xor !empty($res->headers['x-amz-meta-compressed'])) || (!empty($cache_time) xor !empty($res->headers['x-amz-meta-expires-time'])) || !empty($cache_time) && !empty($res->headers['x-amz-meta-expires-time']) && (int) $cache_time != $res->headers['x-amz-meta-expires-time']);
     if ($to_upload) {
         $headers = array();
         $meta_headers = array();
         if (!empty($cache_time)) {
             $headers['Expires'] = gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $cache_time);
             $meta_headers['expires-time'] = $cache_time;
         }
         switch ($ext) {
             case 'css':
                 $headers['Content-Type'] = 'text/css';
                 break;
             case 'js':
                 $headers['Content-Type'] = 'text/javascript';
                 break;
         }
         if (!empty($compress) && is_readable($source) && !empty($headers['Content-Type'])) {
             $headers['Content-Encoding'] = 'gzip';
             $meta_headers['compressed'] = '1';
             $contents = gzencode(file_get_contents($source), $compress);
//.........这里部分代码省略.........
开发者ID:artlabsdesign,项目名称:missbloom,代码行数:101,代码来源:nitro_amazon.php


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