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


PHP S3Request::setAmzHeader方法代码示例

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


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

示例1: copyObject

 /**
  * Copy an object
  *
  * @param string $srcBucket Source bucket name
  * @param string $srcUri Source object URI
  * @param string $bucket Destination bucket name
  * @param string $uri Destination object URI
  * @param constant $acl ACL constant
  * @param array $metaHeaders Optional array of x-amz-meta-* headers
  * @param array $requestHeaders Optional array of request headers (content type, disposition, etc.)
  * @param constant $storageClass Storage class constant
  * @return mixed | false
  */
 public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(), $storageClass = self::STORAGE_CLASS_STANDARD)
 {
     $rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
     $rest->setHeader('Content-Length', 0);
     foreach ($requestHeaders as $h => $v) {
         strpos($h, 'x-amz-') === 0 ? $rest->setAmzHeader($h, $v) : $rest->setHeader($h, $v);
     }
     foreach ($metaHeaders as $h => $v) {
         $rest->setAmzHeader('x-amz-meta-' . $h, $v);
     }
     if ($storageClass !== self::STORAGE_CLASS_STANDARD) {
         // Storage class
         $rest->setAmzHeader('x-amz-storage-class', $storageClass);
     }
     $rest->setAmzHeader('x-amz-acl', $acl);
     $rest->setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, rawurlencode($srcUri)));
     if (sizeof($requestHeaders) > 0 || sizeof($metaHeaders) > 0) {
         $rest->setAmzHeader('x-amz-metadata-directive', 'REPLACE');
     }
     $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::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
         return false;
     }
     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:chiunti,项目名称:amazon-s3-php-class,代码行数:42,代码来源:S3.php

示例2: copyObject

 /**
  * 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
  * @param array $metaHeaders Optional array of x-amz-meta-* headers
  * @param array $requestHeaders Optional array of request headers (content type, disposition, etc.)
  * @return mixed | false
  */
 public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array())
 {
     $rest = new S3Request('PUT', $bucket, $uri);
     $rest->setHeader('Content-Length', 0);
     foreach ($requestHeaders as $h => $v) {
         $rest->setHeader($h, $v);
     }
     foreach ($metaHeaders as $h => $v) {
         $rest->setAmzHeader('x-amz-meta-' . $h, $v);
     }
     $rest->setAmzHeader('x-amz-acl', $acl);
     $rest->setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, $srcUri));
     if (sizeof($requestHeaders) > 0 || sizeof($metaHeaders) > 0) {
         $rest->setAmzHeader('x-amz-metadata-directive', 'REPLACE');
     }
     $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::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     }
     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:rczamor,项目名称:Activ8,代码行数:37,代码来源:S3.php

示例3: copyObject

 public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PUBLIC_READ, $metaHeaders = array(), $requestHeaders = array())
 {
     $rest = new S3Request('PUT', $bucket, $uri);
     $rest->setHeader('Content-Length', 0);
     foreach ($requestHeaders as $h => $v) {
         $rest->setHeader($h, $v);
     }
     foreach ($metaHeaders as $h => $v) {
         $rest->setAmzHeader('x-amz-meta-' . $h, $v);
     }
     $rest->setAmzHeader('x-amz-acl', $acl)->setAmzHeader('x-amz-copy-source', sprintf('/%s/%s', $srcBucket, $srcUri));
     if (sizeof($requestHeaders) > 0 || sizeof($metaHeaders) > 0) {
         $rest->setAmzHeader('x-amz-metadata-directive', 'REPLACE');
     }
     $rest = $rest->getResponse();
     if ($rest->error !== false || $rest->code !== 200) {
         throw new Exception(sprintf("S3::copyObject(%s, %s, %s, %s): [%s] %s", $srcBucket, $srcUri, $bucket, $uri, $rest->code, 'Unexpected HTTP status'));
     }
     return isset($rest->body->LastModified, $rest->body->ETag) ? array('time' => date('Y-m-d H:i:s', strtotime((string) $rest->body->LastModified)), 'hash' => substr((string) $rest->body->ETag, 1, -1)) : false;
 }
开发者ID:comdan66,项目名称:TaipeiTowns,代码行数:20,代码来源:S3.php

示例4: copyObject

 /**
  * 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 static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = self::ACL_PRIVATE)
 {
     $rest = new S3Request('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) {
         trigger_error(sprintf("S3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     }
     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:nicolasconnault,项目名称:moodle2.0,代码行数:25,代码来源:S3.php

示例5: putObject

 /**
  * Put an object
  *
  * @param mixed $input Input data
  * @param string $bucket Bucket name
  * @param string $uri Object URI
  * @param constant $acl ACL constant
  * @param array $metaHeaders Array of x-amz-meta-* headers
  * @param array $requestHeaders Array of request headers or content type as a string
  * @return boolean
  */
 public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array())
 {
     if ($input === false) {
         return false;
     }
     $rest = new S3Request('PUT', $bucket, $uri, self::$__api_host);
     if (is_string($input)) {
         $input = array('data' => $input, 'size' => strlen($input), 'md5sum' => base64_encode(md5($input, true)));
     }
     // Data
     if (isset($input['fp'])) {
         $rest->fp =& $input['fp'];
     } elseif (isset($input['file'])) {
         $rest->fp = @fopen($input['file'], 'rb');
     } elseif (isset($input['data'])) {
         $rest->data = $input['data'];
     }
     // Content-Length (required)
     if (isset($input['size']) && $input['size'] >= 0) {
         $rest->size = $input['size'];
     } else {
         if (isset($input['file'])) {
             $rest->size = filesize($input['file']);
         } elseif (isset($input['data'])) {
             $rest->size = strlen($input['data']);
         }
     }
     // Custom request headers (Content-Type, Content-Disposition, Content-Encoding)
     if (is_array($requestHeaders)) {
         foreach ($requestHeaders as $h => $v) {
             $rest->setHeader($h, $v);
         }
     } elseif (is_string($requestHeaders)) {
         // Support for legacy contentType parameter
         $input['type'] = $requestHeaders;
     }
     // Content-Type
     if (!isset($input['type'])) {
         if (isset($requestHeaders['Content-Type'])) {
             $input['type'] =& $requestHeaders['Content-Type'];
         } elseif (isset($input['file'])) {
             $input['type'] = self::__getMimeType($input['file']);
         } else {
             $input['type'] = 'application/octet-stream';
         }
     }
     // We need to post with Content-Length and Content-Type, MD5 is optional
     if ($rest->size >= 0 && ($rest->fp !== false || $rest->data !== false)) {
         $rest->setHeader('Content-Type', $input['type']);
         if (isset($input['md5sum'])) {
             $rest->setHeader('Content-MD5', $input['md5sum']);
         }
         $rest->setAmzHeader('x-amz-acl', $acl);
         foreach ($metaHeaders as $h => $v) {
             $rest->setAmzHeader('x-amz-meta-' . $h, $v);
         }
         $rest->getResponse();
     } else {
         $rest->response->error = array('code' => 0, 'message' => 'Missing input parameters');
     }
     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::putObject(): [%s] %s", $rest->response->error['code'], $rest->response->error['message']), E_USER_WARNING);
         return false;
     }
     return true;
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:80,代码来源:S3.php

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

示例7: copyObject

 /**
  * 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
  * @return mixed | false
  */
 public static function copyObject($srcBucket, $srcUri, $bucket, $uri)
 {
     $rest = new S3Request('PUT', $bucket, $uri);
     $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 S3Exception($rest->error['code'], "Could not copy object from {$srcBucket}/{$srcUri} to {$bucket}/{$uri}: " . $rest->error['message']);
         return false;
     }
     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:pneff,项目名称:binarypool,代码行数:23,代码来源:S3.php

示例8: putObject

	/**
	* Put an object
	*
	* @param mixed $input Input data
	* @param string $bucket Bucket name
	* @param string $uri Object URI
	* @param constant $acl ACL constant
	* @param array $metaHeaders Array of x-amz-meta-* headers
	* @param string $contentType Content type
	* @return boolean
	*/
	public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $contentType = null) {
		if ($input == false) return false;
		$rest = new S3Request('PUT', $bucket, $uri);

		if (is_string($input)) $input = array(
			'data' => $input, 'size' => strlen($input),
			'md5sum' => base64_encode(md5($input, true))
		);

		// Data
		if (isset($input['fp']))
			$rest->fp =& $input['fp'];
		elseif (isset($input['file']))
			$rest->fp = @fopen($input['file'], 'rb');
		elseif (isset($input['data']))
			$rest->data = $input['data'];

		// Content-Length (required)
		if (isset($input['size']) && $input['size'] > 0)
			$rest->size = $input['size'];
		else {
			if (isset($input['file']))
				$rest->size = filesize($input['file']);
			elseif (isset($input['data']))
				$rest->size = strlen($input['data']);
		}

		// Content-Type
		if ($contentType !== null)
			$input['type'] = $contentType;
		elseif (!isset($input['type']) && isset($input['file']))
			$input['type'] = self::__getMimeType($input['file']);
		else
			$input['type'] = 'application/octet-stream';

		// We need to post with the content-length and content-type, MD5 is optional
		if ($rest->size > 0 && ($rest->fp !== false || $rest->data !== false)) {
			$rest->setHeader('Content-Type', $input['type']);
			if (isset($input['md5sum'])) $rest->setHeader('Content-MD5', $input['md5sum']);

			$rest->setAmzHeader('x-amz-acl', $acl);
			foreach ($metaHeaders as $h => $v) $rest->setAmzHeader('x-amz-meta-'.$h, $v);
			$rest->getResponse();
		} else
			$rest->response->error = array('code' => 0, 'message' => 'Missing input parameters');

		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::putObject(): [%s] %s", $rest->response->error['code'], $rest->response->error['message']), E_USER_WARNING);
			return false;
		}
		return true;
	}
开发者ID:natepixel,项目名称:reason_package,代码行数:65,代码来源:S3.php


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