Skip to content

Behavior Options

The FileStorage.FileStorage behavior wires upload handling into your table's save/delete lifecycle. Attach it in your table's initialize():

php
$this->addBehavior('FileStorage.FileStorage', Configure::read('FileStorage.behaviorConfig'));

Options

OptionTypeDefaultDescription
fileStorageFileStoragerequiredThe FileStorage instance used to store files.
fileProcessorProcessorInterface|nullnullImage/file processor for generating variants.
fileValidatorstring|UploadValidatorInterface|nullnullValidator class or instance for upload validation.
fileFieldstring'file'The form field name that contains the uploaded file.
defaultStorageConfigstring'Local'Default storage adapter name.
ignoreEmptyFilebooltrueSkip processing when no file is uploaded.
dataTransformerDataTransformerInterface|nullnullEntity ↔ file-object transformer used by the image variant queue task.

Notes

fileField

By default the behavior looks for a 'file' field, so your form control should be named *.file. To use a different name, set fileField and name your control accordingly. See Usage.

fileProcessor

Pass an ImageProcessor (or a StackProcessor combining several processors) to generate image variants on upload. See Image variants and versioning.

fileValidator

A class name or instance implementing FileStorage\Model\Validation\UploadValidatorInterface. See Validation.

dataTransformer

Must be a FileStorage\FileStorage\DataTransformerInterface instance; anything else is ignored. When unset, a DataTransformer bound to the storage table is used. This is consumed by the image variant queue task — see The variant command.

Released under the MIT License.