detritus

MultipartBodyclass

A multipart/form-data body that's encoded on every send, its files are never copied (unlike undici's FormData) Encodes the same bytes as undici's FormData, only the boundary differs

On this page

A multipart/form-data body that's encoded on every send, its files are never copied (unlike undici's FormData) Encodes the same bytes as undici's FormData, only the boundary differs

import { MultipartBody } from 'detritus-rest';
4 properties4 methodssrc/multipart.ts:29

Constructor

new MultipartBody

new MultipartBody()

Properties

_resolvingStreams
Promise<void> | null
Default null
boundary
string
readonly
parts
readonly
Default []

Accessors

contentType
string
get
hasPendingStreams
boolean
get

Methods

append()

src/multipart.ts:46
append(name: string, value: any, filename?: string): void

Like FormData.append(), a blob without a filename is named after its File name or blob

appendFile()

src/multipart.ts:63
appendFile(name: string, value: any, filename: string, contentType?: string): void

A file part, a stream value is read in on the first send and a non-binary one is sent as its string

encode()

src/multipart.ts:111
encode(): { length: number; stream: ReadableStream<Uint8Array<ArrayBufferLike>> }

A new stream of the body and its length, can be called for every send

resolveStreams()

async src/multipart.ts:92
resolveStreams(): Promise<void>

Reads the pending streams into chunks once, they're held so the body can be sent again A failed read stays failed, its stream is partly read