Skip to main content

PluginOptions

PluginOptions: object

Type declaration

allowedFileExtensions?

optional allowedFileExtensions: string[]

the list of allowed file extensions

maxFileSize?

optional maxFileSize: number

the maximum file size in bytes

pathColumnName

pathColumnName: string

The name of the column where the path to the uploaded file is stored. On place of this column, a file upload field will be shown.

preview

preview: object

preview.previewUrl()?

optional previewUrl: ({s3Path}) => string

Used to display preview (if it is image) in list and show views. Defaulted to the AWS S3 presigned URL if resource is private or public URL if resource is public. Can be used to generate custom e.g. CDN(e.g. Cloudflare) URL to worm up cache and deliver preview faster.

Example:

previewUrl: ({record, path}) => `https://my-bucket.s3.amazonaws.com/${path}`,

Parameters

ParameterType
{s3Path}any

Returns

string

preview.showInList

showInList: boolean

By default preview is shown in the show view only. If you want to show it in the list view as well, set this to true

s3ACL?

optional s3ACL: string

ACL which will be set to uploaded file, e.g. 'public-read'. If you want to use 'public-read', it is your responsibility to set the "ACL Enabled" to true in the S3 bucket policy and Uncheck "Block all public access" in the bucket settings.

s3AccessKeyId

s3AccessKeyId: string

S3 access key id

s3Bucket

s3Bucket: string

S3 bucket name where we will upload the files, e.g. 'my-bucket'

s3Path()

s3Path: ({originalFilename, originalExtension, contentType}) => string

The path where the file will be uploaded to the S3 bucket, same path will be stored in the database in the column specified in pathColumnName

example:

s3Path: ({record, originalFilename}) => `/aparts/${record.id}/${originalFilename}`

Parameters

ParameterType
{originalFilename, originalExtension, contentType}any

Returns

string

s3Region

s3Region: string

S3 region, e.g. 'us-east-1'

s3SecretAccessKey

s3SecretAccessKey: string

S3 secret access key