import { type MultipartParserOptions, type MultipartPart } from '@remix-run/multipart-parser'; /** * The base class for errors thrown by the form data parser. */ export declare class FormDataParseError extends Error { constructor(message: string, options?: ErrorOptions); } /** * An error thrown when the maximum number of files allowed in a request is exceeded. */ export declare class MaxFilesExceededError extends FormDataParseError { constructor(maxFiles: number); } /** * A file that was uploaded as part of a `multipart/form-data` request. */ export declare class FileUpload extends File { /** * The name of the `` field used to upload the file. */ readonly fieldName: string; constructor(part: MultipartPart, fieldName: string); } /** * A function used for handling file uploads. * * @param file The uploaded file * @returns A value to store in `FormData`, or `void`/`null` to skip */ export interface FileUploadHandler { /** * Transforms an uploaded file into the value stored in the parsed {@link FormData}. */ (file: FileUpload): void | null | string | Blob | Promise; } /** * Options for parsing form data. */ export interface ParseFormDataOptions extends MultipartParserOptions { /** * The maximum number of files that can be uploaded in a single request. If this limit is * exceeded, a `MaxFilesExceededError` will be thrown. * * @default 20 */ maxFiles?: number; } /** * Parses a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) body into a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) * object. This is useful when accessing the data contained in a HTTP `multipart/form-data` request * generated by a HTML `
` element. * * This is a drop-in replacement for [the built-in `request.formData()` API](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) * with the main difference being the ability to customize the handling of file uploads. Instead of * keeping all files in memory, the `uploadHandler` allows you to store the file on disk or a * cloud storage service. * * @param request The `Request` object to parse * @param uploadHandler A function that handles file uploads. It receives a `File` object and may return any value that is valid in a `FormData` object * @returns A `Promise` that resolves to a `FormData` object containing the parsed data */ export declare function parseFormData(request: Request, uploadHandler?: FileUploadHandler): Promise; /** * @param request The `Request` object to parse * @param options Options for the parser * @param uploadHandler A function that handles file uploads. It receives a `File` object and may return any value that is valid in a `FormData` object */ export declare function parseFormData(request: Request, options?: ParseFormDataOptions, uploadHandler?: FileUploadHandler): Promise; //# sourceMappingURL=form-data.d.ts.map