Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback


A middleware framework for handling HTTP with Deno 🐿️ 🦕
Extremely Popular
Go to Latest
interface FormDataReadOptions
import { type FormDataReadOptions } from "";

Options which impact how the form data is decoded for a FormDataReader. All these options have sensible defaults for most applications, but can be modified for different use cases. Many of these options can have an impact on the stability of a server, especially if there is someone attempting a denial of service attack on your server, so be careful when changing the defaults.


bufferSize: number

The size of the buffer to read from the request body at a single time. This defaults to 1mb.

customContentTypes: Record<string, string>

A mapping of custom media types that are supported, mapped to their extension when determining the extension for a file. The key should be an all lowercase media type with the value being the extension (without an initial period), to be used when decoding the file.


Form data that is sent with content having a type of text/vdn.custom will be decoded and assigned a filename ending with .txt:

import { Application } from "";

const app = new Application();
app.use(async (ctx) => {
  const body = ctx.request.body();
  if (body.type === "form-data") {
    const formatData = await{
      customContentTypes: {
        "text/vnd.custom": "txt"
maxFileSize: number

The maximum file size (in bytes) that can be handled. This defaults to 10MB when not specified. This is to try to avoid DOS attacks where someone would continue to try to send a "file" continuously until a host limit was reached crashing the server or the host. Also see maxSize.

maxSize: number

The maximum size (in bytes) of a file to hold in memory, and not write to disk. This defaults to 0, so that all multipart form files are written to disk. When set to a positive integer, if the form data file is smaller, it will be retained in memory and available in the .content property of the FormDataFile object. If the file exceeds the maxSize it will be written to disk and the .filename property will contain the full path to the output file.

outPath: string

When writing form data files to disk, the output path. This will default to a temporary path generated by Deno.makeTempDir().

prefix: string

When a form data file is written to disk, it will be generated with a random filename and have an extension based off the content type for the file. prefix can be specified though to prepend to the file name.