diff --git a/Model/Behavior/BindableBehavior.php b/Model/Behavior/BindableBehavior.php index edfe850..269d43c 100644 --- a/Model/Behavior/BindableBehavior.php +++ b/Model/Behavior/BindableBehavior.php @@ -321,7 +321,7 @@ public function afterSave(Model $model, $created, $options = array()){ 'region' => Configure::read('Filebinder.S3.region'), 'version' => 'latest' ); - + $bucket = !empty($bindFields[$fieldName]['bucket']) ? $bindFields[$fieldName]['bucket'] : Configure::read('Filebinder.S3.bucket'); if (empty($bucket)) { //__('Validation Error: S3 Parameter Error'); @@ -1013,8 +1013,13 @@ protected function bindFile(Model $model, $data = array()) { //__('Validation Error: S3 Parameter Error'); return false; } - $options = array('key' => Configure::read('Filebinder.S3.key'), - 'secret' => Configure::read('Filebinder.S3.secret'), + $options = array( + 'credentials' => array( + 'key' => Configure::read('Filebinder.S3.key'), + 'secret' => Configure::read('Filebinder.S3.secret'), + ), + 'region' => Configure::read('Filebinder.S3.region'), + 'version' => 'latest' ); $bucket = !empty($bindFields[$fieldName]['bucket']) ? $bindFields[$fieldName]['bucket'] : Configure::read('Filebinder.S3.bucket'); if (empty($bucket)) { @@ -1022,10 +1027,6 @@ protected function bindFile(Model $model, $data = array()) { return false; } $s3 = S3Client::factory($options); - $region = !empty($bindFields[$fieldName]['region']) ? $bindFields[$fieldName]['region'] : Configure::read('Filebinder.S3.region'); - if (!empty($region)) { - $s3->setRegion($region); - } $urlPrefix = !empty($bindFields[$fieldName]['urlPrefix']) ? $bindFields[$fieldName]['urlPrefix'] : Configure::read('Filebinder.S3.urlPrefix'); $tmpFilePath = '/tmp/' . sha1(uniqid('', true)); diff --git a/Test/Case/Model/Behavior/BindableBehaviorTest.php b/Test/Case/Model/Behavior/BindableBehaviorTest.php index 7aee511..c84592b 100644 --- a/Test/Case/Model/Behavior/BindableBehaviorTest.php +++ b/Test/Case/Model/Behavior/BindableBehaviorTest.php @@ -418,7 +418,7 @@ public function testSaveS3(){ 'tmpPath' => CACHE, 'filePath' => $filePath, 'bucket' => AWS_S3_BUCKET, - 'acl' => Aws\S3\Enum\CannedAcl::PUBLIC_READ, + 'acl' => 'public-read', ), ); @@ -482,7 +482,7 @@ public function testRestoreS3(){ 'tmpPath' => CACHE, 'filePath' => $filePath, 'bucket' => AWS_S3_BUCKET, - 'acl' => Aws\S3\Enum\CannedAcl::PRIVATE_ACCESS, + 'acl' => 'private', ), ); @@ -552,7 +552,7 @@ public function testRestoreFalseS3(){ 'tmpPath' => CACHE, 'filePath' => $filePath, 'bucket' => AWS_S3_BUCKET, - 'acl' => Aws\S3\Enum\CannedAcl::PRIVATE_ACCESS, + 'acl' => 'private', ), );