From 938b855940a1bacf2a6dd2faf25d0c7aff56aeb6 Mon Sep 17 00:00:00 2001 From: Eric Norris Date: Mon, 13 Oct 2014 14:15:59 -0400 Subject: [PATCH] Allow x-amz headers in $requestHeaders param. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this, custom headers like ‘x-amz-server-side-encryption-customer-algorithm’ will work. --- S3.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/S3.php b/S3.php index 0b1564b2..f421c0c0 100644 --- a/S3.php +++ b/S3.php @@ -642,7 +642,8 @@ public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE // Custom request headers (Content-Type, Content-Disposition, Content-Encoding) if (is_array($requestHeaders)) - foreach ($requestHeaders as $h => $v) $rest->setHeader($h, $v); + foreach ($requestHeaders as $h => $v) + strpos($h, 'x-amz-') === 0 ? $rest->setAmzHeader($h, $v) : $rest->setHeader($h, $v); elseif (is_string($requestHeaders)) // Support for legacy contentType parameter $input['type'] = $requestHeaders; @@ -797,7 +798,8 @@ public static function copyObject($srcBucket, $srcUri, $bucket, $uri, $acl = sel { $rest = new S3Request('PUT', $bucket, $uri, self::$endpoint); $rest->setHeader('Content-Length', 0); - foreach ($requestHeaders as $h => $v) $rest->setHeader($h, $v); + 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);