Merge pull request #60 from lmammino/azure-blob-storage

Added support for azure blob storage
This commit is contained in:
Leszek Prabucki 2013-08-24 03:58:34 -07:00
commit bd695f9194
4 changed files with 91 additions and 2 deletions

View File

@ -0,0 +1,48 @@
<?php
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
class AzureBlobStorageAdapterFactory implements AdapterFactoryInterface
{
/**
* {@inheritDoc}
*/
public function create(ContainerBuilder $container, $id, array $config)
{
$definition = $container
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.azure_blob_storage'))
->addArgument(new Reference($config['blob_proxy_factory_id']))
->addArgument($config['container_name'])
->addArgument($config['create_container'])
->addArgument($config['detect_content_type']);
}
/**
* {@inheritDoc}
*/
public function getKey()
{
return 'azure_blob_storage';
}
/**
* {@inheritDoc}
*/
public function addConfiguration(NodeDefinition $builder)
{
$builder
->children()
->scalarNode('blob_proxy_factory_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('container_name')->isRequired()->cannotBeEmpty()->end()
->booleanNode('create_container')->defaultValue(false)->end()
->booleanNode('detect_content_type')->defaultValue(true)->end()
->end()
;
}
}

View File

@ -230,6 +230,45 @@ knp_gaufrette:
mtime: 123456890123 mtime: 123456890123
``` ```
## Azure Blob Storage (azure\_blob\_storage)
Adapter for Microsoft Azure Blob Storage service. To use this adapter you need to install the
[Azure SDK for php](http://www.windowsazure.com/en-us/develop/php/common-tasks/download-php-sdk/) into your project.
Further more you need a valid *connection string* and you must define a Blob Proxy factory service with it. You can use
the default `\Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactory` this way:
``` yaml
# app/config/config.yml
services:
azure_blob_proxy_factory:
class: Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactory
arguments: [%azure_blob_storage_connection_string%]
```
You must set the parameter `azure_blob_storage_connection_string` to contain your windows azure blob storage connection
string. You can retrieve your connection string in your [Windows Azure management console](https://manage.windowsazure.com).
### Parameters
* `blob_proxy_factory_id` Reference to the blob proxy factory service
* `container_name` The name of the container
* `create_container` Boolean value that indicates whether to create the container if it does not exists (*optional*: default *false*)
* `detect_content_type` Boolean value that indicates whether to auto determinate and set the content type on new blobs (*optional*: default *true*)
### Example
``` yaml
# app/config/config.yml
knp_gaufrette:
adapters:
foo:
azure_blob_storage:
blob_proxy_factory_id: azure_blob_proxy_factory
container_name: my_container
create_container: true
```
## GridFS (gridfs) ## GridFS (gridfs)
Adapter that allows you to use a MongoDB GridFS for storing files. Adapter that allows you to use a MongoDB GridFS for storing files.

View File

@ -26,6 +26,9 @@
<service id="knp_gaufrette.adapter.factory.opencloud" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\OpenCloudAdapterFactory"> <service id="knp_gaufrette.adapter.factory.opencloud" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\OpenCloudAdapterFactory">
<tag name="gaufrette.adapter.factory" /> <tag name="gaufrette.adapter.factory" />
</service> </service>
<service id="knp_gaufrette.adapter.factory.azure_blob_storage" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\AzureBlobStorageAdapterFactory">
<tag name="gaufrette.adapter.factory" />
</service>
<service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory"> <service id="knp_gaufrette.adapter.factory.gridfs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\GridFSAdapterFactory">
<tag name="gaufrette.adapter.factory" /> <tag name="gaufrette.adapter.factory" />
</service> </service>
@ -48,4 +51,3 @@
</services> </services>
</container> </container>

View File

@ -30,6 +30,7 @@
<argument /><!-- Create container --> <argument /><!-- Create container -->
<argument /><!-- Detect content type --> <argument /><!-- Detect content type -->
</service> </service>
<service id="knp_gaufrette.adapter.azure_blob_storage" class="Gaufrette\Adapter\AzureBlobStorage" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.gridfs" class="Gaufrette\Adapter\GridFS" abstract="true" public="false" /> <service id="knp_gaufrette.adapter.gridfs" class="Gaufrette\Adapter\GridFS" abstract="true" public="false" />
<service id="knp_gaufrette.adapter.mogilefs" class="Gaufrette\Adapter\MogileFS" abstract="true" public="false"> <service id="knp_gaufrette.adapter.mogilefs" class="Gaufrette\Adapter\MogileFS" abstract="true" public="false">
<argument /><!-- domain --> <argument /><!-- domain -->
@ -48,4 +49,3 @@
</services> </services>
</container> </container>