Skip to content

Commit

Permalink
Allow no-credentials for S3 Client (#486)
Browse files Browse the repository at this point in the history
* Allow no-credentials for S3 Client

* Styling stuff

Signed-off-by: Alexandru Busuioc <[email protected]>

* fix the test pipeline

Signed-off-by: Alexandru Busuioc <[email protected]>

Signed-off-by: Alexandru Busuioc <[email protected]>
  • Loading branch information
alexbusu authored Oct 30, 2022
1 parent 5964177 commit 40fedcb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:

- name: 'Install project dependencies'
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable
vendor/bin/simple-phpunit install
Expand Down
15 changes: 9 additions & 6 deletions src/Configuration/ElFinderConfigurationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,19 @@ private function configureFlysystem($opt, $adapter, $serviceName)

break;
case 'aws_s3_v3':
$client = new S3Client([
'credentials' => [
'key' => $opt['aws_s3_v3']['key'],
'secret' => $opt['aws_s3_v3']['secret'],
],
$s3Options = [
'region' => $opt['aws_s3_v3']['region'],
'version' => $opt['aws_s3_v3']['version'],
'endpoint' => $opt['aws_s3_v3']['endpoint'],
'use_path_style_endpoint' => $opt['aws_s3_v3']['use_path_style_endpoint'],
]);
];
if (!empty($opt['aws_s3_v3']['key']) && !empty($opt['aws_s3_v3']['secret'])) {
$s3Options['credentials'] = [
'key' => $opt['aws_s3_v3']['key'],
'secret' => $opt['aws_s3_v3']['secret'],
];
}
$client = new S3Client($s3Options);
$filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix'], null, null, $opt['aws_s3_v3']['options']));

break;
Expand Down

0 comments on commit 40fedcb

Please sign in to comment.