Skip to content

Commit

Permalink
add support for Amazon S3
Browse files Browse the repository at this point in the history
  • Loading branch information
rande committed Mar 27, 2011
1 parent ff6f7f5 commit 52a74a5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
15 changes: 15 additions & 0 deletions DependencyInjection/SonataMediaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ public function configureFilesystemAdapter(ContainerBuilder $container, $config)
$definition->addArgument($configuration['passive']);
$definition->addArgument($configuration['create']);
}

// add the default configuration for the S3 filesystem
if($container->hasDefinition('sonata.media.adapter.filesystem.s3') && isset($config['filesystem']['sonata.media.adapter.filesystem.s3'])) {
$configuration = $config['filesystem']['sonata.media.adapter.filesystem.s3'];

$definition = $container->getDefinition('sonata.media.adapter.filesystem.s3');
$definition->setArgument(0, new Reference('sonata.media.adapter.service.s3'));
$definition->setArgument(1, $configuration['bucket']);
$definition->setArgument(2, $configuration['create']);

$definition = $container->getDefinition('sonata.media.adapter.service.s3');
$definition->setArgument(0, $configuration['accessKey']);
$definition->setArgument(1, $configuration['secretKey']);
$definition->setArgument(2, $configuration['region']);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Available services

- sonata.media.filesystem.local : The local filesystem (default)
- sonata.media.filesystem.ftp : FTP

- sonata.media.filesystem.s3 : Amazon S3

CDN

Expand Down
17 changes: 16 additions & 1 deletion Resources/config/media.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@

<!-- filesystem abstraction service -->
<service id="sonata.media.adapter.filesystem.local" class="Gaufrette\Filesystem\Adapter\Local" />
<service id="sonata.media.adapter.filesystem.ftp" class="Gaufrette\Filesystem\Adapter\Ftp" />
<service id="sonata.media.adapter.filesystem.ftp" class="Gaufrette\Filesystem\Adapter\Ftp" />
<service id="sonata.media.adapter.service.s3" class="Zend\Service\Amazon\S3\S3" >
<argument />
<argument />
<argument />
</service>
<service id="sonata.media.adapter.filesystem.s3" class="Gaufrette\Filesystem\Adapter\AmazonS3" >
<argument />
<argument />
<argument />
</service>


<service id="sonata.media.filesystem.ftp" class="Gaufrette\Filesystem\Filesystem" >
<argument type="service" id="sonata.media.adapter.filesystem.ftp" />
Expand All @@ -31,6 +42,10 @@
<argument type="service" id="sonata.media.adapter.filesystem.local" />
</service>

<service id="sonata.media.filesystem.s3" class="Gaufrette\Filesystem\Filesystem">
<argument type="service" id="sonata.media.adapter.filesystem.s3" />
</service>

<!-- CDN abstraction service -->
<service id="sonata.media.cdn.server" class="Sonata\MediaBundle\CDN\Server">
<argument />
Expand Down
1 change: 1 addition & 0 deletions Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Available services

- sonata.media.filesystem.local : The local filesystem (default)
- sonata.media.filesystem.ftp : FTP
- sonata.media.filesystem.s3 : Amazon S3

CDN

Expand Down
7 changes: 7 additions & 0 deletions Resources/doc/reference/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ Full configuration option
passive: false
create: false
sonata.media.adapter.filesystem.s3:
bucket:
accessKey:
secretKey:
create: false
region: # this settings does not seems to be implemented with Zend Framework
providers:
sonata.media.provider.file:
resizer: false
Expand Down

0 comments on commit 52a74a5

Please sign in to comment.