Skip to content

NodeMultipart

Node.js multipart parsing for HTTP multipart/form-data request bodies.

NodeMultipart adapts a Node Readable plus incoming HTTP headers into Effect's shared multipart model. It can expose form parts as a stream or collect a complete persisted form by writing file uploads to scoped temporary files through the current FileSystem and Path services. fileToReadable returns the underlying Node readable stream for file parts produced by this parser.

3 exports Added in v4.0.0 Source

Constructors

persisted

Added in v4.0.0 Source

Parses multipart data from a Node readable request body and persists file parts using the current FileSystem, Path, and Scope services.

Signature

declare function persisted(
  source: Readable,
  headers: IncomingHttpHeaders,
): Effect<Persisted, MultipartError, FileSystem | Path | Scope>;

stream

Added in v4.0.0 Source

Parses multipart data from a Node readable request body and headers into a stream of Multipart.Part values, converting parser failures to MultipartError.

Signature

declare function stream(
  source: Readable,
  headers: IncomingHttpHeaders,
): Stream<Part, MultipartError>;

Converting

Returns the underlying Node readable stream for a multipart file produced by the Node multipart parser.

Signature

declare function fileToReadable(file: File): Readable;