Skip to content

encodeFormData

reference
1 min readUpdated

Kind: Function

Source: atloria-monorepo/packages/ui-core/src/components/api-explorer/multipart.ts

Encode a FormData for transport through the try-it proxy.

The proxy speaks JSON — it has to, since it is also carrying the target URL and headers — and a File does not survive JSON.stringify (it becomes {}). Before this, a proxied upload sent an empty object and reported whatever the upstream made of it. Base64 costs a third in size, which is why the caller caps the total; see MAX_PROXY_UPLOAD_BYTES.

Signature

ts
async function encodeFormData(form: FormData): Promise<{ parts: EncodedPart[]; bytes: number }>

Parameters

NameType
formFormData

Returns: Promise<{ parts: EncodedPart[]; bytes: number }>

Was this page helpful?

Download as PDF