File Storage Locations

Improvements?

Let us know by posting here.

Remote Storage Locations

Concrete CMS allows defining multiple file storage locations via the Dashboard. The default type is "Local," a directory on the same server. Additional types, like Amazon S3, can be added through packages.

File Storage Locations List Adding New File Storage Location

A registered file storage location can be set as default, with files added to the file manager stored there by default. File-by-file storage location selection is also available.

File Storage Location Selection

Creating a File Storage Location Type

To create a custom File Storage Location type:

Package Controller Creation

Start with a standard package controller:

<?php

namespace Concrete\Package\CustomStorage;

defined('C5_EXECUTE') or die(_('Access Denied.'));

use \Concrete\Core\Package\Package;

class Controller extends Package
{
    protected $pkgHandle = 'custom_storage';
    protected $appVersionRequired = '5.7.5RC1';
    protected $pkgVersion = '1.0';

    public function getPackageDescription()
    {
        return t('A custom file storage location type.');
    }

    public function getPackageName()
    {
        return t('Custom Storage');
    }

}

Installing File Storage Location Type

Install the custom type during package installation:

public function install()
{
    $pkg = parent::install();
    \Concrete\Core\File\StorageLocation\Type\Type::add('type_foo', 'Custom Type', $pkg);
}

To manage class loading, include:

protected $pkgAutoloaderMapCoreExtensions = true;

Custom Configuration Class

Create a custom configuration class implementing ConfigurationInterface:

<?php 
namespace Concrete\Package\CustomStorage\File\StorageLocation\Configuration;

use \Concrete\Core\File\StorageLocation\Configuration\ConfigurationInterface;
use \Concrete\Core\File\StorageLocation\Configuration\Configuration;

class TypeFooConfiguration extends Configuration implements ConfigurationInterface
{
    // Implement required methods from ConfigurationInterface
}

Custom Form for File Storage Location

Create a custom form file at packages/your_package/elements/storage_location_types/your_handle.php for configuration options.

Completing the Process

Add the custom file storage location type, create the configuration object it uses, and make a custom options page for configuration in the Dashboard. External libraries can be integrated for actual storage location interactions.

For reference, examine the LocalConfiguration object for local file system storage management.