Commit a10a1b34 authored by Thorsten Buss's avatar Thorsten Buss

FIX: remove slash, cause with S3 ver3 SDK, there were removed the first letter of the dir

add AWS Version param
parent 0e5c2c80
......@@ -9,16 +9,16 @@
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.15.5",
"version": "3.18.15",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "e6d8b291b45009b310a174bcabad3de1c864e176"
"reference": "a50c0971d42867ac8184c52c5f35b27255a695b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/e6d8b291b45009b310a174bcabad3de1c864e176",
"reference": "e6d8b291b45009b310a174bcabad3de1c864e176",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/a50c0971d42867ac8184c52c5f35b27255a695b2",
"reference": "a50c0971d42867ac8184c52c5f35b27255a695b2",
"shasum": ""
},
"require": {
......@@ -85,7 +85,7 @@
"s3",
"sdk"
],
"time": "2016-02-25 22:52:38"
"time": "2016-06-02 20:13:40"
},
{
"name": "guzzlehttp/guzzle",
......
......@@ -218,14 +218,16 @@ class AdapterAmazonS3Ver2 extends AmazonS3 implements GaufretteAdapter, UrlAware
$this->ensureBucketExists();
// add slash to beginning and remove from end
$prefix = preg_replace('/^[\/]*([^\/].*)[\/]?$/', '/$1', $prefix);
$prefix = preg_replace('/^[\/]*([^\/].*)[\/]?$/', '$1', $prefix);
$iterator = $this->getKeyIterator($prefix);
$keys = array();
$paths = array();
$prefix_dir = rtrim(substr($prefix, -1) != '/'?dirname($prefix):$prefix, '/');
$dirLength = ltrim(strlen($this->getDirectory() . $prefix_dir), '/'); // remove the starting slash
if ($prefix_dir == '.')
$prefix_dir = '';
$dirLength = strlen(trim($this->getDirectory() . $prefix_dir, '/')); // remove the starting slash
foreach ($iterator as $item) {
$file = substr($item['Key'], $dirLength);
if (!$file) continue;
......
......@@ -9,6 +9,11 @@ use BNRepo\Repository\Adapter\AdapterAmazonS3Ver2;
class RepositoryS3 extends Repository {
/**
* the version of the API which should be used
*/
const AWS_S3_API_VERSION = '2006-03-01';
protected function createAdapter($cfg) {
if (!isset($cfg['aws_key']) || empty($cfg['aws_key']))
throw new ParamNotFoundException('param aws_key in S3-repo not set');
......@@ -25,7 +30,7 @@ class RepositoryS3 extends Repository {
'key' => $cfg['aws_key'],
'secret' => $cfg['aws_secret'],
],
'version' => @$cfg['aws_version'] ?: 'latest',
'version' => self::AWS_S3_API_VERSION,
'region' => $cfg['aws_region'],
);
if (isset($cfg['aws_options']) && is_array($cfg['aws_options']))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment