UNPKG

@coolio/http

Version:
67 lines (66 loc) 2.44 kB
/// <reference types="node" /> import { Readable, Writable } from 'stream'; export declare const SUPPORTS_BROWSER_FORM_DATA: boolean; export declare const isBrowserFormData: (value: any) => value is FormData; export declare const isBlob: (value: any) => value is Blob; export declare const readBlob: (blob: Blob) => Promise<Buffer>; export declare const getFileMeta: (value: Readable | Blob, existingMeta?: CFormDataEntryMetadata | undefined) => { filename: string; contentType: any; knownLength: any; } | { filename: string; header?: string | Record<string, string | string[]> | undefined; filepath?: string | undefined; name?: string | undefined; contentType: any; knownLength: any; }; export interface FormDataFromOptions { forceImplementation?: 'native' | 'custom'; } export interface CFormDataEntryMetadata { header?: string | Record<string, string | string[]>; filepath?: string; filename?: string; name?: string; contentType?: string; knownLength?: number; } export declare type CFormDataValue = string | Blob | Readable; export interface CFormDataEntryValue { value: CFormDataValue; meta?: CFormDataEntryMetadata; } /** * Create readable "multipart/form-data" streams. * Can be used to submit forms * and file uploads to other web applications. */ export declare class CFormData { static LINE_BREAK: string; static DEFAULT_CONTENT_TYPE: string; private data; private boundary?; constructor(data?: any); static from(data: any, { forceImplementation }?: FormDataFromOptions): FormData | CFormData; static isFormData(data: any): data is FormData | CFormData; append(name: string, value: any, meta?: CFormDataEntryMetadata): void; delete(name: string): void; getAll(name: string): CFormDataValue[]; set(name: string, value: CFormDataValue | Blob, meta?: CFormDataEntryMetadata): void; get(name: string): CFormDataValue | null; has(name: string): boolean; forEach(callbackfn: (value: CFormDataValue, key: string, parent: CFormData) => void): void; getBoundary(): string; getHeaders(): { 'content-type': string; }; pipe(writable: Writable): void; getBuffer(): Promise<Buffer>; toString(): string; private insert; private multiPartHeader; private lastBoundary; } //# sourceMappingURL=formData.d.ts.map