Skip to content

Commit daa27e6

Browse files
committed
Added SSE parameter to putObject
1 parent 57d9fa8 commit daa27e6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

S3.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ class S3
4444

4545
const STORAGE_CLASS_STANDARD = 'STANDARD';
4646
const STORAGE_CLASS_RRS = 'REDUCED_REDUNDANCY';
47-
47+
48+
const SSE_NONE = '';
49+
const SSE_AES256 = 'AES256';
50+
4851
/**
4952
* The AWS Access key
5053
*
@@ -565,9 +568,10 @@ public static function inputResource(&$resource, $bufferSize, $md5sum = '')
565568
* @param array $metaHeaders Array of x-amz-meta-* headers
566569
* @param array $requestHeaders Array of request headers or content type as a string
567570
* @param constant $storageClass Storage class constant
571+
* @param constant $serverSideEncryption Server-side encryption
568572
* @return boolean
569573
*/
570-
public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(), $storageClass = self::STORAGE_CLASS_STANDARD)
574+
public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE, $metaHeaders = array(), $requestHeaders = array(), $storageClass = self::STORAGE_CLASS_STANDARD, $serverSideEncryption = self::SSE_NONE)
571575
{
572576
if ($input === false) return false;
573577
$rest = new S3Request('PUT', $bucket, $uri, self::$endpoint);
@@ -615,6 +619,9 @@ public static function putObject($input, $bucket, $uri, $acl = self::ACL_PRIVATE
615619
if ($storageClass !== self::STORAGE_CLASS_STANDARD) // Storage class
616620
$rest->setAmzHeader('x-amz-storage-class', $storageClass);
617621

622+
if ($serverSideEncryption !== self::SSE_NONE) // Server-side encryption
623+
$rest->setAmzHeader('x-amz-server-side-encryption', $serverSideEncryption);
624+
618625
// We need to post with Content-Length and Content-Type, MD5 is optional
619626
if ($rest->size >= 0 && ($rest->fp !== false || $rest->data !== false))
620627
{

0 commit comments

Comments
 (0)