File Field Configuration

The following documentation is for SuiteCRM Version 8.9.0+

Intro

File fields allow you to associate uploaded files (such as documents or images) with your entities. These fields are managed by the media uploader system and support various storage backends.

File Field Detail

How File Fields Work

When a field is configured as type file, it enables file upload and management for that field. The system uses the configured storage backend to store and retrieve files, and links the uploaded file metadata to the entity record.

To use a file field, you must specify the storage_type in the field’s metadata configuration. This tells the system which storage backend to use for the uploaded files.

To understand how the media uploader and storage system works, please refer to the File Storage Configuration Reference.

It is also important to know the lifecycle of media objects to understand how files are managed in the system.

Configuration Example

To define an file field in your vardefs:

Minimal configuration:

'file' => [
    'name' => 'file',
    'vname' => 'LBL_FILE',
    'type' => 'file',
    'source' => 'non-db',
    'reportable' => false,
    'importable' => false,
    'metadata' => [
        'storage_type' => 'private-documents', // Required!
    ],
],

Full configuration with max upload size option:

'file' => [
    'name' => 'file',
    'vname' => 'LBL_FILE',
    'type' => 'file',
    'source' => 'non-db',
    'reportable' => false,
    'importable' => false,
    'metadata' => [
        'storage_type' => 'private-documents', // Required!
        'upload_maxsize' => 10000000, // Optional, defaults to global config
    ],
],

Configuration Options

Option Description Required

type

Must be set to file

Yes

storage_type

The storage backend to use for this field. Must match a configured storage (e.g., private-documents, public-images). See the File Storage Configuration Reference.

Yes

upload_maxsize

Maximum allowed file size in bytes.

No

Declaring Storage Types

The storage_type must correspond to a storage defined in your media configuration (see File Storage Configuration Reference). Example storage types include:

  • private-documents

  • archived-documents

  • private-images

  • public-images

  • public-documents

If you do not declare a valid storage_type, file uploads will not work for this field.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.