Skip to content

remix/multipart-parser/future · Function

View Source

parseMultipartStream

Summary

Parse a multipart/* message stream and yield each part as a MultipartPart as soon as its headers arrive. Part content is streamed from the message as you read it, never buffered.

Parts are read in order, so read each part's content before continuing to the next part. When you continue, the parser waits for a read you started to finish and discards any content you didn't read.

Note: This is a low-level API that requires manual handling of the content and boundary. If you're building a web server, consider using import('./multipart-request.ts').parseMultipartRequest instead.

Signature

function parseMultipartStream(
  stream: ReadableStream<Uint8Array<ArrayBufferLike>>,
  options: ParseMultipartOptions,
): AsyncGenerator<MultipartPart, void, unknown>

Parameters

stream

A stream containing multipart data as a ReadableStream<Uint8Array>

options

Options for the parser

Returns

An async generator that yields MultipartPart objects