Skip to main content Link Search Menu Expand Document (external link)

Multipart overview

Added in v1.0.0


Table of contents


constructors

makeChannel

Signature

export declare const makeChannel: <IE>(
  headers: Record<string, string>,
  bufferSize?: number
) => Channel.Channel<Chunk.Chunk<Part>, Chunk.Chunk<Uint8Array>, MultipartError | IE, IE, unknown, unknown>

Added in v1.0.0

makeConfig

Signature

export declare const makeConfig: (headers: Record<string, string>) => Effect.Effect<Multipasta.BaseConfig>

Added in v1.0.0

toPersisted

Signature

export declare const toPersisted: (
  stream: Stream.Stream<Part, MultipartError>,
  writeFile?: ((path: string, file: File) => Effect.Effect<void, MultipartError, FileSystem.FileSystem>) | undefined
) => Effect.Effect<Persisted, MultipartError, any>

Added in v1.0.0

errors

MultipartError

Signature

export declare const MultipartError: new (options: {
  readonly reason: MultipartError["reason"]
  readonly error: unknown
}) => MultipartError

Added in v1.0.0

MultipartError (interface)

Signature

export interface MultipartError extends YieldableError {
  readonly [ErrorTypeId]: ErrorTypeId
  readonly _tag: "MultipartError"
  readonly reason: "FileTooLarge" | "FieldTooLarge" | "BodyTooLarge" | "TooManyParts" | "InternalError" | "Parse"
  readonly error: unknown
}

Added in v1.0.0

fiber refs

fieldMimeTypes

Signature

export declare const fieldMimeTypes: FiberRef.FiberRef<Chunk.Chunk<string>>

Added in v1.0.0

maxFieldSize

Signature

export declare const maxFieldSize: FiberRef.FiberRef<Brand.Branded<bigint, "Size">>

Added in v1.0.0

maxFileSize

Signature

export declare const maxFileSize: FiberRef.FiberRef<Option.Option<Brand.Branded<bigint, "Size">>>

Added in v1.0.0

maxParts

Signature

export declare const maxParts: FiberRef.FiberRef<Option.Option<number>>

Added in v1.0.0

withFieldMimeTypes

Signature

export declare const withFieldMimeTypes: {
  (mimeTypes: ReadonlyArray<string>): <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
  <R, E, A>(effect: Effect.Effect<A, E, R>, mimeTypes: ReadonlyArray<string>): Effect.Effect<A, E, R>
}

Added in v1.0.0

withMaxFieldSize

Signature

export declare const withMaxFieldSize: {
  (size: FileSystem.SizeInput): <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
  <R, E, A>(effect: Effect.Effect<A, E, R>, size: FileSystem.SizeInput): Effect.Effect<A, E, R>
}

Added in v1.0.0

withMaxFileSize

Signature

export declare const withMaxFileSize: {
  (size: Option.Option<any>): <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
  <R, E, A>(effect: Effect.Effect<A, E, R>, size: Option.Option<any>): Effect.Effect<A, E, R>
}

Added in v1.0.0

withMaxParts

Signature

export declare const withMaxParts: {
  (count: Option.Option<number>): <R, E, A>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
  <R, E, A>(effect: Effect.Effect<A, E, R>, count: Option.Option<number>): Effect.Effect<A, E, R>
}

Added in v1.0.0

models

Field (interface)

Signature

export interface Field extends Part.Proto {
  readonly _tag: "Field"
  readonly key: string
  readonly contentType: string
  readonly value: string
}

Added in v1.0.0

File (interface)

Signature

export interface File extends Part.Proto {
  readonly _tag: "File"
  readonly key: string
  readonly name: string
  readonly contentType: string
  readonly content: Stream.Stream<Uint8Array, MultipartError>
}

Added in v1.0.0

Part (type alias)

Signature

export type Part = Field | File

Added in v1.0.0

Persisted (interface)

Signature

export interface Persisted {
  readonly [key: string]: ReadonlyArray<PersistedFile> | string
}

Added in v1.0.0

PersistedFile (interface)

Signature

export interface PersistedFile extends Part.Proto {
  readonly _tag: "PersistedFile"
  readonly key: string
  readonly name: string
  readonly contentType: string
  readonly path: string
}

Added in v1.0.0

refinements

isField

Signature

export declare const isField: (u: unknown) => u is Field

Added in v1.0.0

isFile

Signature

export declare const isFile: (u: unknown) => u is File

Added in v1.0.0

isPart

Signature

export declare const isPart: (u: unknown) => u is Part

Added in v1.0.0

isPersistedFile

Signature

export declare const isPersistedFile: (u: unknown) => u is PersistedFile

Added in v1.0.0

schema

filesSchema

Signature

export declare const filesSchema: Schema.Schema<readonly PersistedFile[]>

Added in v1.0.0

schemaJson

Signature

export declare const schemaJson: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: ParseOptions | undefined
) => {
  (field: string): (persisted: Persisted) => Effect.Effect<A, ParseResult.ParseError, R>
  (persisted: Persisted, field: string): Effect.Effect<A, ParseResult.ParseError, R>
}

Added in v1.0.0

schemaPersisted

Signature

export declare const schemaPersisted: <R, I extends Partial<Persisted>, A>(
  schema: Schema.Schema<A, I, R>,
  options?: ParseOptions | undefined
) => (persisted: Persisted) => Effect.Effect<A, ParseResult.ParseError, R>

Added in v1.0.0

type ids

ErrorTypeId

Signature

export declare const ErrorTypeId: typeof ErrorTypeId

Added in v1.0.0

ErrorTypeId (type alias)

Signature

export type ErrorTypeId = typeof ErrorTypeId

Added in v1.0.0

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0

utils

Part (namespace)

Added in v1.0.0

Proto (interface)

Signature

export interface Proto extends Inspectable {
  readonly [TypeId]: TypeId
  readonly _tag: string
}

Added in v1.0.0