parseFormData
Summary
Parses a Request body into a FormData
object. This is useful when accessing the data contained in a HTTP multipart/form-data request
generated by a HTML <form> element.
This is a drop-in replacement for the built-in request.formData() API
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.
Signature
function parseFormData(
request: Request,
uploadHandler: FileUploadHandler,
): Promise<FormData>;
function parseFormData(
request: Request,
options: ParseFormDataOptions,
uploadHandler: FileUploadHandler,
): Promise<FormData>;
Params
request
The Request object to parse
options
Options for the parser
uploadHandler
A function that handles file uploads. It receives a File object and may return any value that is valid in a FormData object