Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AsyncAws S3 #209

Merged
merged 5 commits into from
Jun 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions DependencyInjection/Factory/Adapter/AsyncAwsS3Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter;

use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Reference;
use Oneup\FlysystemBundle\DependencyInjection\Factory\AdapterFactoryInterface;

class AsyncAwsS3Factory implements AdapterFactoryInterface
{
public function getKey()
{
return 'async_aws_s3';
}

public function create(ContainerBuilder $container, $id, array $config)
{
$container
->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()
;
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Resources/config/adapters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<argument /><!-- Archive -->
<argument /><!-- Prefix -->
</service>
<service id="oneup_flysystem.adapter.async_aws_s3" class="AsyncAws\Flysystem\S3\S3FilesystemV1" abstract="true" public="false">
<argument /><!-- Client -->
<argument /><!-- Bucket -->
<argument /><!-- Prefix -->
</service>
<service id="oneup_flysystem.adapter.awss3v2" class="League\Flysystem\AwsS3v2\AwsS3Adapter" abstract="true" public="false">
<argument /><!-- Client -->
<argument /><!-- Bucket -->
Expand Down
3 changes: 3 additions & 0 deletions Resources/config/factories.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<service id="oneup_flysystem.adapter_factory.zip" class="Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter\ZipFactory">
<tag name="oneup_flysystem.adapter_factory" />
</service>
<service id="oneup_flysystem.adapter_factory.async_aws_s3" class="Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter\AsyncAwsS3Factory">
<tag name="oneup_flysystem.adapter_factory" />
</service>
<service id="oneup_flysystem.adapter_factory.awss3v2" class="Oneup\FlysystemBundle\DependencyInjection\Factory\Adapter\AwsS3V2Factory">
<tag name="oneup_flysystem.adapter_factory" />
</service>
Expand Down
33 changes: 33 additions & 0 deletions Resources/doc/adapter_async_aws_s3.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down