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


PHP S3Request::setParameter方法代码示例

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


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

示例1: getAccessControlPolicy

 /**
  * Get object or bucket Access Control Policy
  *
  * @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, self::$endpoint);
     $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) {
         self::__triggerError(sprintf("S3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
         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:chiunti,项目名称:amazon-s3-php-class,代码行数:44,代码来源:S3.php

示例2: 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

示例3: bucket_contents

	/**
	 * Gets the contents of a bucket
	 * 
	 * @param $bucket
	 * @param $prefix
	 * @param $marker
	 * @param $maxKeys
	 * @param $delimiter
	 * @return unknown_type
	 */
	public function bucket_contents($bucket, $prefix = null, $marker = null, $maxKeys = null, $delimiter = null) 
	{
		$rest = new S3Request($this->id,$this->secret,true,'GET', $bucket, '');
	
		if ($prefix !== null && $prefix !== '') 
			$rest->setParameter('prefix', $prefix);

		if ($marker !== null && $marker !== '') 
			$rest->setParameter('marker', $marker);

		if ($maxKeys !== null && $maxKeys !== '') 
			$rest->setParameter('max-keys', $maxKeys);
		
		if ($delimiter !== null && $delimiter !== '') 
			$rest->setParameter('delimiter', $delimiter);
		
		$response = $rest->getResponse();
		
		if ($response->error === false && $response->code !== 200)
			$response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
		
		if ($response->error !== false) 
			throw new AWSException(sprintf("S3::getBucket(): [%s] %s", $response->error['code'], $response->error['message']));

		$results = array();

		$lastMarker = null;
		if (isset($response->body, $response->body->Contents))
			foreach ($response->body->Contents as $c) 
			{
				$results[(string)$c->Key] = array(
					'name' => (string)$c->Key,
					'time' => strtotime((string)$c->LastModified),
					'size' => (int)$c->Size,
					'hash' => substr((string)$c->ETag, 1, -1)
				);
				$lastMarker = (string)$c->Key;
				//$response->body->IsTruncated = 'true'; break;
			}


		if (isset($response->body->IsTruncated) && (string)$response->body->IsTruncated == 'false') 
			return $results;

		// Loop through truncated results if maxKeys isn't specified
		if ($maxKeys == null && $lastMarker !== null && (string)$response->body->IsTruncated == 'true')
			do 
			{
				$rest = new S3Request($this->id,$this->secret,true,'GET', $bucket, '');

				if ($prefix !== null) 
					$rest->setParameter('prefix', $prefix);

				$rest->setParameter('marker', $lastMarker);

				if (($response = $rest->getResponse(true)) == false || $response->code !== 200) 
					break;

				if (isset($response->body, $response->body->Contents))
					foreach ($response->body->Contents as $c) 
					{
						$results[(string)$c->Key] = array(
							'name' => (string)$c->Key,
							'time' => strtotime((string)$c->LastModified),
							'size' => (int)$c->Size,
							'hash' => substr((string)$c->ETag, 1, -1)
						);
						
						$lastMarker = (string)$c->Key;
					}
				} 
				while ($response !== false && (string)$response->body->IsTruncated == 'true');

		return $results;
	}
开发者ID:nikels,项目名称:HeavyMetal,代码行数:85,代码来源:s3.php

示例4: getBucket

 public static function getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null)
 {
     $rest = new S3Request('GET', $bucket, '');
     if ($prefix !== null && $prefix !== '') {
         $rest->setParameter('prefix', $prefix);
     }
     if ($marker !== null && $prefix !== '') {
         $rest->setParameter('marker', $marker);
     }
     if ($maxKeys !== null && $prefix !== '') {
         $rest->setParameter('max-keys', $maxKeys);
     }
     $response = $rest->getResponse();
     if ($response->error === false && $response->code !== 200) {
         $response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
     }
     if ($response->error !== false) {
         trigger_error(sprintf("S3::getBucket(): [%s] %s", $response->error['code'], $response->error['message']), E_USER_WARNING);
         return false;
     }
     $results = array();
     $lastMarker = null;
     if (isset($response->body, $response->body->Contents)) {
         foreach ($response->body->Contents as $c) {
             $results[(string) $c->Key] = array('name' => (string) $c->Key, 'time' => strToTime((string) $c->LastModified), 'size' => (int) $c->Size, 'hash' => substr((string) $c->ETag, 1, -1));
             $lastMarker = (string) $c->Key;
             //$response->body->IsTruncated = 'true'; break;
         }
     }
     if (isset($response->body->IsTruncated) && (string) $response->body->IsTruncated == 'false') {
         return $results;
     }
     // Loop through truncated results if maxKeys isn't specified
     if ($maxKeys == null && $lastMarker !== null && (string) $response->body->IsTruncated == 'true') {
         do {
             $rest = new S3Request('GET', $bucket, '');
             if ($prefix !== null) {
                 $rest->setParameter('prefix', $prefix);
             }
             $rest->setParameter('marker', $lastMarker);
             if (($response = $rest->getResponse(true)) == false || $response->code !== 200) {
                 break;
             }
             if (isset($response->body, $response->body->Contents)) {
                 foreach ($response->body->Contents as $c) {
                     $results[(string) $c->Key] = array('name' => (string) $c->Key, 'time' => strToTime((string) $c->LastModified), 'size' => (int) $c->Size, 'hash' => substr((string) $c->ETag, 1, -1));
                     $lastMarker = (string) $c->Key;
                 }
             }
         } while ($response !== false && (string) $response->body->IsTruncated == 'true');
     }
     return $results;
 }
开发者ID:piqiu0304,项目名称:S3ForMe-PHP,代码行数:53,代码来源:S3.php

示例5: 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) {
         throw new S3Exception($rest->error['code'], "Could not get access control policy {$bucket}/{$uri}: " . $rest->error['message']);
         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:pneff,项目名称:binarypool,代码行数:46,代码来源:S3.php


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