MultipartPart
Summary
A part of a multipart/* HTTP message, yielded as soon as its headers arrive. Its content is
streamed from the message and can be read once, with MultipartPart.body,
MultipartPart.bytes, MultipartPart.text, or for await...of.
Signature
class MultipartPart {
constructor(header: Uint8Array, content: PartContent): MultipartPart
// Accessors
get body(): ReadableStream<Uint8Array<ArrayBuffer>>
get bodyUsed(): boolean
get filename(): string | undefined
get headers(): MultipartHeaders
get isFile(): boolean
get mediaType(): string | undefined
get name(): string | undefined
// Methods
[asyncIterator](): AsyncIterator<Uint8Array<ArrayBuffer>>
bytes(): Promise<Uint8Array<ArrayBuffer>>
text(): Promise<string>
}
Constructor
Parameters
header
The raw header bytes
content
The part's content
Accessors
body
A stream of this part's content. Accessing it starts reading the content, so the next part isn't yielded until the stream is read to the end, canceled, or errors.
bodyUsed
True once this part's content has been read, a read of it has started, or its MultipartPart.body has been accessed.
filename
The filename from the part's Content-Disposition header, preferring a decoded filename*
over filename when available. This is untrusted client input without filesystem sanitization.
Do not use it, or a File.name derived from it, directly as a filesystem path. Generate a
storage name in your application instead.
headers
The decoded headers associated with this part, keyed by lower-case header name.
isFile
True if this part originated from a file upload.
mediaType
The media type of the part.
name
The name of the part, usually the name of the field in the <form> that submitted the request.
Methods
[asyncIterator](): AsyncIterator<Uint8Array<ArrayBuffer>>
Iterates over the chunks of this part's content.
bytes(): Promise<Uint8Array<ArrayBuffer>>
Reads all of this part's content into a single Uint8Array.
text(): Promise<string>
Reads all of this part's content as a UTF-8 string. In multipart/form-data messages, this is
useful for reading the value of parts that originated from <input type="text"> fields.
Note: Do not use this for binary data, use part.body or part.bytes() instead.