Version 5 supported
This version of Silverstripe CMS is still supported though will not receive any additional features. Go to documentation for the most recent stable version.

Bulk uploader

A component for uploading images and/or files in bulk into DataObject managed by the GridField.

Usage 1

Simplest usage, add the component to your GridFieldConfig as below. The component will find the first Image or File has_one relation to use on the managed DataObject.

use Colymba\BulkUpload\BulkUploader;

$config->addComponent(new BulkUploader());

Usage 2

You can specify which Image or File field to use and a specific DataObject class name to use.

  • $fileRelationName (string, optional): The name of the Image or File has_one field to use (If your relation is set as 'MyImage' => Image::class, the parameter should be 'MyImage')
  • $recordClassName (string, optional): The class name of the DataObject to create (Useful if for example your GridField holds DataObjects of different classes, like when used with the GridFieldAddNewMultiClass component.)
use Colymba\BulkUpload\BulkUploader;

$config->addComponent(new BulkUploader($fileRelationName, $recordClassName));

Configuration

Component configuration

The component's option can be configurated through the setConfig functions like this:

use Colymba\BulkUpload\BulkUploader;

$config->getComponentByType(BulkUploader::class)->setConfig($reference, $value);

The available configuration options are:

  • fileRelationName: sets the name of the Image or File has_one field to use (i.e. 'MyImage')

UploadField configuration

The underlying UploadField can be configured via BulkUploader::setUfSetup() which is used to pass function calls on to the UploadField itself

For example, to set the upload folder, which is set by calling setFolderName on the UploadField, you would use the following:

use Colymba\BulkUpload\BulkUploader;

$config->getComponentByType(BulkUploader::class)
    ->setUfSetup('setFolderName', 'myFolder')

Please see UploadField and the Upload for more info.

Bulk editing

To get a quick edit shortcut to all the newly upload files, please also add the BulkManager component to your GridFieldConfig.