@types/formidable

  • Version 1.2.3
  • Published
  • 17.2 kB
  • 1 dependency
  • MIT license

Install

npm i @types/formidable
yarn add @types/formidable
pnpm add @types/formidable

Overview

TypeScript definitions for formidable

Index

Variables

variable formidable

const formidable: {
(options?: formidable.Options): Formidable;
defaultOptions: formidable.DefaultOptions;
plugins: formidable.EnabledPlugins;
errors: typeof errors;
File: typeof PersistentFile;
PersistentFile: typeof PersistentFile;
VolatileFile: typeof VolatileFile;
Formidable: typeof Formidable;
formidable: (options?: formidable.Options) => Formidable;
IncomingForm: typeof Formidable;
parsers: typeof parsers;
} & formidable.MappedParsers;

    Interfaces

    interface EmitData

    interface EmitData {}

      property formname

      formname: any;

        property key

        key?: string | number | undefined;

          property name

          name: 'fileBegin' | 'file';

            property value

            value: File | string;

              interface EventData

              interface EventData {}

                property buffer

                buffer: string;

                  property end

                  end: string;

                    property formname

                    formname: string;

                      property key

                      key: string;

                        property name

                        name: EventNames;

                          property start

                          start: string;

                            property value

                            value: string;

                              interface Fields

                              interface Fields {}

                                index signature

                                [field: string]: string | string[];

                                  interface File

                                  interface File {}

                                    property hash

                                    hash?: string | 'sha1' | 'md5' | 'sha256' | null | undefined;
                                    • If options.hash calculation was set, you can read the hex digest out of this var.

                                    property lastModifiedDate

                                    lastModifiedDate?: Date | null | undefined;
                                    • A Date object (or null) containing the time this file was last written to. Mostly here for compatibility with the [W3C File API Draft](http://dev.w3.org/2006/webapi/FileAPI/).

                                    property name

                                    name: string | null;
                                    • The name this file had according to the uploading client.

                                    property path

                                    path: string;
                                    • The path this file is being written to. You can modify this in the 'fileBegin' event in case you are unhappy with the way formidable generates a temporary path for your files.

                                    property size

                                    size: number;
                                    • The size of the uploaded file in bytes. If the file is still being uploaded (see 'fileBegin' event), this property says how many bytes of the file have been written to disk yet.

                                    property type

                                    type: string | null;
                                    • The mime type of this file, according to the uploading client.

                                    method toJSON

                                    toJSON: () => FileJSON;
                                    • This method returns a JSON-representation of the file, allowing you to JSON.stringify() the file which is useful for logging and responding to requests.

                                      https://github.com/node-formidable/formidable#filetojson

                                    method toString

                                    toString: () => string;

                                      interface FileJSON

                                      interface FileJSON extends Pick<File, 'size' | 'path' | 'name' | 'type' | 'hash'> {}
                                      • https://github.com/node-formidable/formidable#file

                                      property filename

                                      filename: string;

                                        property length

                                        length: number;

                                          property mime

                                          mime: string;

                                            property mtime

                                            mtime: Date | null;

                                              interface Files

                                              interface Files {}

                                                index signature

                                                [file: string]: File | File[];

                                                  interface Options

                                                  interface Options {}

                                                    property allowEmptyFiles

                                                    allowEmptyFiles?: boolean | undefined;
                                                    • allow upload empty files

                                                      true

                                                    property enabledPlugins

                                                    enabledPlugins?: string[] | undefined;

                                                      property encoding

                                                      encoding?: BufferEncoding | undefined;
                                                      • sets encoding for incoming form fields

                                                        'utf-8'

                                                      property fileWriteStreamHandler

                                                      fileWriteStreamHandler?: (() => void) | undefined;
                                                      • which by default writes to host machine file system every file parsed; The function should return an instance of a Writable stream that will receive the uploaded file data. With this option, you can have any custom behavior regarding where the uploaded file data will be streamed for. If you are looking to write the file uploaded in other types of cloud storages (AWS S3, Azure blob storage, Google cloud storage) or private file storage, this is the option you're looking for. When this option is defined the default behavior of writing the file in the host machine file system is lost.

                                                        null

                                                      property hash

                                                      hash?: string | false | undefined;
                                                      • include checksums calculated for incoming files, set this to some hash algorithm, see crypto.createHash for available algorithms

                                                        false

                                                      property keepExtensions

                                                      keepExtensions?: boolean | undefined;
                                                      • to include the extensions of the original files or not

                                                        false

                                                      property maxFields

                                                      maxFields?: number | undefined;
                                                      • limit the number of fields, set 0 for unlimited

                                                        1000

                                                      property maxFieldsSize

                                                      maxFieldsSize?: number | undefined;
                                                      • limit the amount of memory all fields together (except files) can allocate in bytes

                                                        20 * 1024 * 1024

                                                      property maxFileSize

                                                      maxFileSize?: number | undefined;
                                                      • limit the size of uploaded file

                                                        200 * 1024 * 1024

                                                      property minFileSize

                                                      minFileSize?: number | undefined;
                                                      • the minium size of uploaded file

                                                        1

                                                      property multiples

                                                      multiples?: boolean | undefined;
                                                      • when you call the .parse method, the files argument (of the callback) will contain arrays of files for inputs which submit multiple files using the HTML5 multiple attribute. Also, the fields argument will contain arrays of values for fields that have names ending with '[]'

                                                        false

                                                      property uploadDir

                                                      uploadDir?: string | undefined;
                                                      • the directory for placing file uploads in. You can move them later by using fs.rename()

                                                        os.tmpdir()

                                                      interface Part

                                                      interface Part extends Stream {}

                                                        property filename

                                                        filename?: string | undefined;

                                                          property headers

                                                          headers: Record<string, string>;

                                                            property mime

                                                            mime?: string | undefined;

                                                              property name

                                                              name: string;

                                                                Type Aliases

                                                                type BufferEncoding

                                                                type BufferEncoding =
                                                                | 'ascii'
                                                                | 'base64'
                                                                | 'binary'
                                                                | 'hex'
                                                                | 'latin1'
                                                                | 'ucs-2'
                                                                | 'ucs2'
                                                                | 'utf-8'
                                                                | 'utf16le'
                                                                | 'utf8';

                                                                  type DefaultOptions

                                                                  type DefaultOptions = Required<Omit<Options, 'enabledPlugins'>> & {
                                                                  enabledPlugins: EnabledPlugins;
                                                                  };

                                                                    type EnabledPlugins

                                                                    type EnabledPlugins = {
                                                                    [P in Plugin]: PluginFunction;
                                                                    };

                                                                      type EventNames

                                                                      type EventNames =
                                                                      /**
                                                                      * Emitted when the request was aborted by the user. Right now this can be due to a 'timeout' or
                                                                      * 'close' event on the socket. After this event is emitted, an error event will follow. In the
                                                                      * future there will be a separate 'timeout' event (needs a change in the node core).
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#aborted
                                                                      */
                                                                      | 'aborted'
                                                                      /**
                                                                      * Emitted when the entire request has been received, and all contained files have finished
                                                                      * flushing to disk. This is a great place for you to send your response.
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#end
                                                                      */
                                                                      | 'end'
                                                                      /**
                                                                      * Emitted when there is an error processing the incoming form. A request that experiences an
                                                                      * error is automatically paused, you will have to manually call request.resume() if you want the
                                                                      * request to continue firing 'data' events.
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#error
                                                                      */
                                                                      | 'error'
                                                                      /**
                                                                      * Emitted whenever a field / value pair has been received.
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#field
                                                                      */
                                                                      | 'field'
                                                                      /**
                                                                      * Emitted whenever a field / file pair has been received. file is an instance of File.
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#file-1
                                                                      */
                                                                      | 'file'
                                                                      /**
                                                                      * Emitted whenever a new file is detected in the upload stream. Use this event if you want to
                                                                      * stream the file to somewhere else while buffering the upload on the file system.
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#filebegin
                                                                      */
                                                                      | 'fileBegin'
                                                                      | 'headerEnd'
                                                                      | 'headerField'
                                                                      | 'headersEnd'
                                                                      | 'headerValue'
                                                                      | 'partBegin'
                                                                      | 'partData'
                                                                      /**
                                                                      * Emitted after each incoming chunk of data that has been parsed. Can be used to roll your own
                                                                      * progress bar.
                                                                      *
                                                                      * @link https://github.com/node-formidable/formidable#progress
                                                                      */
                                                                      | 'progress';

                                                                        type MappedParsers

                                                                        type MappedParsers = {
                                                                        [P in keyof typeof parsers]: typeof parsers[P];
                                                                        };

                                                                          type Plugin

                                                                          type Plugin = keyof { [K in Plugins[number]]: K };

                                                                            type PluginFunction

                                                                            type PluginFunction = (formidable: Formidable, options: Partial<Options>) => void;

                                                                              type Plugins

                                                                              type Plugins = ['octetstream', 'querystring', 'multipart', 'json'];

                                                                                Package Files (1)

                                                                                Dependencies (1)

                                                                                Dev Dependencies (0)

                                                                                No dev dependencies.

                                                                                Peer Dependencies (0)

                                                                                No peer dependencies.

                                                                                Badge

                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/formidable.

                                                                                • Markdown
                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/formidable)
                                                                                • HTML
                                                                                  <a href="https://www.jsdocs.io/package/@types/formidable"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>