diff --git a/README.md b/README.md index d0d75fe..6e81596 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Options can be passed into the Signature class as a fifth parameter, below is a | content_type | | Strictly only allow a single content type, blank will allow all. Will fail with a AccessDenied 403 is this condition is not met. | | encryption | false | Sets whether AWS server side encryption should be applied to the uploaded files, so that files will be encrypted with AES256 when at rest. | | custom_url | null | Allow S3 compatible solutions by specifying the domain it should POST to. Must be a valid url (inc. http/https) otherwise will throw InvalidOptionException. | +| accelerate | false | Set Amazon S3 Transfer Acceleration | | additional_inputs | | Any additional inputs to add to the form. This is an array of name => value pairs e.g. ['Content-Disposition' => 'attachment'] | For example: diff --git a/src/Signature.php b/src/Signature.php index 69c5545..0681790 100644 --- a/src/Signature.php +++ b/src/Signature.php @@ -60,6 +60,9 @@ class Signature // a valid url (inc. http/https) otherwise will throw InvalidOptionException. 'custom_url' => null, + // Set Amazon S3 Transfer Acceleration + 'accelerate' => false, + // Any additional inputs to add to the form. This is an array of name => value // pairs e.g. ['Content-Disposition' => 'attachment'] 'additional_inputs' => [] @@ -174,7 +177,10 @@ private function buildAmazonUrl() $middle = ""; } - return "//" . self::SERVICE . $middle . ".amazonaws.com" . "/" . urlencode($this->bucket); + if($this->options['accelerate']) + return "//" . urlencode($this->bucket) . "." . self::SERVICE . "-accelerate.amazonaws.com"; + else + return "//" . self::SERVICE . $middle . ".amazonaws.com" . "/" . urlencode($this->bucket); } /** diff --git a/tests/SignatureTest.php b/tests/SignatureTest.php index 7e79c3d..e692143 100644 --- a/tests/SignatureTest.php +++ b/tests/SignatureTest.php @@ -95,7 +95,7 @@ public function testGetOptions() { $object = new Signature('key', 'secret', 'test', $this->testRegion); $options = $object->getOptions(); - $this->assertTrue(count($options) === 10); + $this->assertTrue(count($options) === 11); $this->assertArrayHasKey('success_status', $options); $this->assertArrayHasKey('acl', $options); $this->assertArrayHasKey('default_filename', $options);