import { HttpMediaType } from '@opra/common'; import busboy from 'busboy'; import { EventEmitter } from 'events'; import type { StrictOmit } from 'ts-gems'; import type { HttpContext } from '../http-context.js'; import { LocalFile } from './local-file.js'; /** * MultipartReader is responsible for parsing multipart/form-data requests. * It uses busboy to stream incoming parts and can handle both fields and files. */ export declare class MultipartReader extends EventEmitter { protected context: HttpContext; protected mediaType?: HttpMediaType | undefined; protected _started: boolean; protected _finished: boolean; protected _cancelled: boolean; protected _form: busboy.Busboy; protected _items: MultipartReader.Item[]; protected _stack: MultipartReader.Item[]; protected tempDirectory: string; scope?: string; constructor(context: HttpContext, options?: MultipartReader.Options, mediaType?: HttpMediaType | undefined); get items(): MultipartReader.Item[]; /** * Retrieves the next item (field or file) from the multipart stream. * * @returns A promise that resolves to the next item, or undefined if no more items are available. * @throws {@link BadRequestError} If a field is unknown or validation fails. */ getNext(): Promise; /** * Retrieves all items from the multipart stream. * * @returns A promise that resolves to an array of all items. */ getAll(): Promise; getAll_(): Promise; cancel(): void; resume(): void; pause(): void; /** * Purges all temporary files created by the reader. * * @returns A promise that resolves when all files are purged. */ purge(): Promise[]>; } export declare class MultipartFile extends LocalFile { readonly kind = "file"; readonly field: string; constructor(field: string, storedPath: string, options?: LocalFile.Options); } export declare namespace MultipartReader { interface Options extends StrictOmit { tempDirectory?: string; scope?: string; } interface Field { kind: 'field'; field: string; value?: any; mimeType?: string; encoding?: string; } type File = MultipartFile; type Item = Field | File; }