/// /// /// import { EventNoticer, Event } from './event'; import * as crypto from 'crypto'; import * as hs from './http_service'; import * as http from 'http'; export declare enum STATUS { PARSER_UNINITIALIZED = 0, START = 1, START_BOUNDARY = 2, HEADER_FIELD_START = 3, HEADER_FIELD = 4, HEADER_VALUE_START = 5, HEADER_VALUE = 6, HEADER_VALUE_ALMOST_DONE = 7, HEADERS_ALMOST_DONE = 8, PART_DATA_START = 9, PART_DATA = 10, PART_END = 11, END = 12 } export interface IFileStream { readonly pathname: string; write(buffer: Buffer, cb: () => void): void; end(cb: () => void): void; } export declare class FileStream implements IFileStream { private _writeStream; private _size; private _lastModifiedDate; get size(): number; readonly filename: string; readonly pathname: string; readonly mimeType: string; get lastModifiedDate(): number; constructor(path: string, name: string, mimeType: string); write(buffer: Buffer, cb: () => void): void; end(cb: () => void): void; } declare class Part { headers: Dict; name: string; filename: string; mime: string; headerField: string; headerValue: string; readonly onData: EventNoticer>; readonly onEnd: EventNoticer>; } export interface ProgressData { bytesReceived: number; bytesExpected: number; } export interface FieldData { name: string; value: string; } export interface FileData { name: string; file: File; } export declare class IncomingForm { private _parser; private _flushing; private _fields_size; private _service; private _error; private _ended; readonly hash: crypto.Hash; readonly fields: Dict; readonly files: Dict; get ended(): boolean; /** * default size 2MB * @type {Number} */ maxFieldsSize: number; /** * default size 5MB * @type {Number} */ maxFilesSize: number; /** * verifyFileMime 'js|jpg|jpeg|png' default as '*' ... * @type {String} */ verifyFileMime: string; keepExtensions: boolean; uploadDir: string; encoding: BufferEncoding; headers: http.IncomingHttpHeaders; type: string; private bytesReceived; private bytesExpected; readonly onAborted: EventNoticer>; readonly onProgress: EventNoticer; readonly onField: EventNoticer; readonly onFileBegin: EventNoticer; readonly onFile: EventNoticer; readonly onError: EventNoticer; readonly onEnd: EventNoticer>; /** * constructor function * @param {HttpService} * @constructor */ constructor(service: hs.HttpService); _canceled(): void; /** * parse */ parse(): void; write(buffer: Buffer): number | undefined; pause(): boolean; resume(): boolean; onPart(part: Part): void; _parseContentType(): void; _throwError(err: Error): void; _parseContentLength(): void; _fileName(headerValue: string): string | undefined; _initMultipart(boundary: string): void; private _initUrlencodedOrJsonOrXml; private _uploadPath; private _maybeEnd; } declare function stateToString(stateNumber: number): string; declare const _default: { IncomingForm: typeof IncomingForm; temp_dir: string; STATUS: typeof STATUS; stateToString: typeof stateToString; }; export default _default;