Validate files based on their min and/or max size.
import { defineFilePond } from 'filepond';
import { locale } from 'filepond/locales/en-gb.js';
import { FileSizeValidator } from 'filepond/extensions/file-size-validator.js';
defineFilePond({
locale,
extensions: [
// Add the FileSizeValidator extension
[FileSizeValidator, {
maxSize: '10MB'
}]
]
})
Configuration
The FileSizeValidator extension accepts an option object of type FileSizeValidatorOptions which defines the properties below.
minSize
Min file size in bytes or a natural file size. Defaults to 0
minSize?: string | number
maxSize
Max file size in bytes or a natural file size. Defaults to Infinity
maxSize?: string | number
byteUnits
The natural file size format to use, defaults to 'mega' if no natural file size supplied for minSize or maxSize
byteUnits?: "mega" | "mebi"