Documentation

6.1 Storage configuration

Integrated allows you to put files in one or multiple storages. These can be local, in the cloud or any other location supported by a Gaufrette adaptor. 

Basic configuration

Integrated uses knplabs/knp-gaufrette-bundle for configuration and a filesystem map. When you've enabled the bundle, this config below is required for a default Integrated installation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// app/config.yml
knp_gaufrette:
    adapters:
        foo:
            local:
                directory: %kernel.root_dir%/../web/uploads/documents
    filesystems:
        foo:
            adapter: foo
 
integrated_storage:
    resolver:
        foo:
            public: /files

Please see the KnpGaufretteBundle documentation for all available options.

Using multiple filesystems

The StorageBundle places the files on all known filesystems when no destination map exists. The order defined in the configuration will be used to determine its primary path.

Storage resolver

When a filesystem has no resolver storage (for protected files) components which use the public URL will not be able to access the file. The filesystems (foo above) in the knp_gaufrette configuration are linked to the integrated_storage configuration. Based on the key(s), a resolver or decision map entry is linked to a filesystem.

Using a decision map

Additionally, to protected entities from being stored in a public accessible resource, a developer can configure filesystems for entities. You can enforce entities to be stored in specific storage(s).

1
2
3
4
5
// app/config.yml
integrated_storage:
    // ...
    decision_map:
        "Integrated\Bundle\ContentBundle\Document\File": [foo]

The redistribution command does not make use of the decision map and copies all files in the given storage.

Protecting files

In some cases the files may not be stored in a publicly available directory. You can do this by adding an additional private local storage. However, files can also be stored on any remote location by not defining a resolver.

A controller might look like the following:

1
2
3
4
<span class="x">// File is a Integrated\Common\Content\Document\FileInterface object    </span>
<span class="p">$</span><span class="nv">response</span><span class="x"> = new Response();</span>
<span class="p">$</span><span class="nv">response</span><span class="x">->setContent(</span><span class="p">$</span><span class="nv">file</span><span class="x">->getContent());</span>
<span class="p">$</span><span class="nv">response</span><span class="x">->setHeaders(</span><span class="p">$</span><span class="nv">file</span><span class="x">->getMetadata()->getHeaders());</span>