basalt / files/src / FileValidation
Interface: FileValidation
Defined in: files/src/files.ts:124
Properties
allowedTypes?
> optional allowedTypes?: string[]
Defined in: files/src/files.ts:128
Allowed content types; supports image/* wildcards.
maxSize?
> optional maxSize?: number
Defined in: files/src/files.ts:126
Max size in bytes.
sniff?
> optional sniff?: boolean | ContentSniffer
Defined in: files/src/files.ts:141
Check the real type of the bytes instead of trusting the declared one.
true uses the built-in signature sniffer (sniffContentType); a function is your own detector (it receives the file's first 64 KiB and returns a MIME type, or null for "unknown"). With sniffing on, an upload whose content contradicts its declared type is rejected with FileTypeMismatchError, allowedTypes is checked against the detected type, the record's contentType is the detected type, and the declared one is kept in metadata.declaredType. Off by default — consider enabling it whenever users upload files other users will open.