From e23d73567b477b8765e7fbe6c095cc2449caaa61 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sun, 21 Jun 2020 14:25:02 +0200 Subject: [PATCH] Add support for AsyncAws S3 (#209) --- .../Factory/Adapter/AsyncAwsS3Factory.php | 40 +++++++++++++++++++ README.md | 1 + Resources/config/adapters.xml | 5 +++ Resources/config/factories.xml | 3 ++ Resources/doc/adapter_async_aws_s3.md | 33 +++++++++++++++ Resources/doc/index.md | 2 + composer.json | 3 +- 7 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 DependencyInjection/Factory/Adapter/AsyncAwsS3Factory.php create mode 100644 Resources/doc/adapter_async_aws_s3.md diff --git a/DependencyInjection/Factory/Adapter/AsyncAwsS3Factory.php b/DependencyInjection/Factory/Adapter/AsyncAwsS3Factory.php new file mode 100644 index 0000000..02cc5da --- /dev/null +++ b/DependencyInjection/Factory/Adapter/AsyncAwsS3Factory.php @@ -0,0 +1,40 @@ +setDefinition($id, new ChildDefinition('oneup_flysystem.adapter.async_aws_s3')) + ->replaceArgument(0, new Reference($config['client'])) + ->replaceArgument(1, $config['bucket']) + ->replaceArgument(2, $config['prefix']) + ->addArgument($config['options']) + ; + } + + public function addConfiguration(NodeDefinition $node) + { + $node + ->children() + ->scalarNode('client')->isRequired()->end() + ->scalarNode('bucket')->isRequired()->end() + ->scalarNode('prefix')->treatNullLike('')->defaultValue('')->end() + ->variableNode('options')->treatNullLike([])->defaultValue([])->end() + ->end() + ; + } +} diff --git a/README.md b/README.md index b2af044..a4eed0e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ OneupFlysystemBundle The OneupFlysystemBundle provides a [Flysystem](https://github.com/thephpleague/flysystem) integration for your Symfony projects. Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one. Currently you can configure the following adapters to use in your Symfony project. +* [AsyncAwsS3](https://async-aws.com/) * [AwsS3](http://aws.amazon.com/de/sdkforphp/) * [AzureBlobStorage](https://azure.microsoft.com/en-us/services/storage/blobs/) * [Dropbox](https://www.dropbox.com/developers) diff --git a/Resources/config/adapters.xml b/Resources/config/adapters.xml index 4ac8743..11eb1c0 100644 --- a/Resources/config/adapters.xml +++ b/Resources/config/adapters.xml @@ -21,6 +21,11 @@ + + + + + diff --git a/Resources/config/factories.xml b/Resources/config/factories.xml index a2febc6..9699878 100644 --- a/Resources/config/factories.xml +++ b/Resources/config/factories.xml @@ -14,6 +14,9 @@ + + + diff --git a/Resources/doc/adapter_async_aws_s3.md b/Resources/doc/adapter_async_aws_s3.md new file mode 100644 index 0000000..eb9e443 --- /dev/null +++ b/Resources/doc/adapter_async_aws_s3.md @@ -0,0 +1,33 @@ +# Use the AsyncAwsS3 adapter + +In order to use the AsyncAwsS3 adapter, you first need to create a S3 client service. +This can be done with the following configuration. Read more about instantiating +the S3 client at [async-aws.com](https://async-aws.com/clients/) or use the +[AsyncAws SymfonyBundle](https://async-aws.com/integration/symfony-bundle.html). + +```yml +services: + acme.async_s3_client: + class: AsyncAws\S3\S3Client + arguments: + - region: 'eu-central-1' + accessKeyId: 'AKIAIOSFODNN7EXAMPLE' + accessKeySecret: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' +``` + +Set this service as the value of the `client` key in the `oneup_flysystem` configuration. + +```yml +oneup_flysystem: + adapters: + acme.flysystem_adapter: + async_aws_s3: + client: acme.s3_client + bucket: 'my_image_bucket' + prefix: '' +``` + +## More to know + +* [Create and use your filesystem](filesystem_create.md) +* [Add a cache](filesystem_cache.md) diff --git a/Resources/doc/index.md b/Resources/doc/index.md index 205cbcc..2086094 100644 --- a/Resources/doc/index.md +++ b/Resources/doc/index.md @@ -21,6 +21,7 @@ Composer will now fetch and install this bundle in the vendor directory `vendor/ **Note**: There are some additional dependencies you will need to install for some of the features: +* The AsyncAwsS3 adapter requires `"async-aws/flysystem-s3"` * The AwsS3v3 adapter requires `"league/flysystem-aws-s3-v3"` * The AwsS3v2 adapter requires `"league/flysystem-aws-s3-v2"` * The Azure Blob Storage adapter requires `"league/flysystem-azure-blob-storage"` @@ -77,6 +78,7 @@ oneup_flysystem: There are a bunch of adapters for you to use: +* [AsyncAwsS3](adapter_async_aws_s3.md) * [AwsS3](adapter_awss3.md) * [AzureBlobStorage](adapter_azureblob.md) * [Copy.com](https://github.com/copy-app/php-client-library) diff --git a/composer.json b/composer.json index eeafb74..a019143 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,8 @@ "litipk/flysystem-fallback-adapter": "^0.1", "jenko/flysystem-gaufrette": "^1.0", "superbalist/flysystem-google-storage": "^4.0", - "league/flysystem-replicate-adapter": "^1.0" + "league/flysystem-replicate-adapter": "^1.0", + "async-aws/flysystem-s3": "^0.4.0" }, "suggest": {