filetype
filetype<
TInput>(config):FiletypeConfig<TInput> &object
Defined in: packages/storage/src/schema.ts:64
Define a file type with its constraints and key generation strategy.
Applies defaults for optional fields: uploadable defaults to true,
replace to false, multipartThreshold to "5mb", and partSize to "10mb".
Type Parameters
Section titled “Type Parameters”TInput
Section titled “TInput”TInput = Record<string, unknown>
The shape of caller-provided input available in the key function and hooks.
Parameters
Section titled “Parameters”config
Section titled “config”FiletypeConfig<TInput>
The file type configuration.
Returns
Section titled “Returns”FiletypeConfig<TInput> & object
The config with defaults applied, fully resolved.
Example
Section titled “Example”import { filetype } from "@cfast/storage";
const avatars = filetype({ bucket: "UPLOADS", accept: ["image/jpeg", "image/png", "image/webp"], maxSize: "2mb", key: (file, ctx) => `avatars/${ctx.user.id}/${file.name}`, replace: true,});