UNPKG

2.39 kBTypeScriptView Raw
1/// <reference types="node" />
2/**
3 * @see https://github.com/expressjs/multer
4 *
5 * @publicApi
6 */
7export interface MulterOptions {
8 dest?: string | Function;
9 /** The storage engine to use for uploaded files. */
10 storage?: any;
11 /**
12 * An object specifying the size limits of the following optional properties. This object is passed to busboy
13 * directly, and the details of properties can be found on https://github.com/mscdex/busboy#busboy-methods
14 */
15 limits?: {
16 /** Max field name size (Default: 100 bytes) */
17 fieldNameSize?: number;
18 /** Max field value size (Default: 1MB) */
19 fieldSize?: number;
20 /** Max number of non- file fields (Default: Infinity) */
21 fields?: number;
22 /** For multipart forms, the max file size (in bytes)(Default: Infinity) */
23 fileSize?: number;
24 /** For multipart forms, the max number of file fields (Default: Infinity) */
25 files?: number;
26 /** For multipart forms, the max number of parts (fields + files)(Default: Infinity) */
27 parts?: number;
28 /** For multipart forms, the max number of header key=> value pairs to parse Default: 2000(same as node's http). */
29 headerPairs?: number;
30 };
31 /** Keep the full path of files instead of just the base name (Default: false) */
32 preservePath?: boolean;
33 fileFilter?(req: any, file: {
34 /** Field name specified in the form */
35 fieldname: string;
36 /** Name of the file on the user's computer */
37 originalname: string;
38 /** Encoding type of the file */
39 encoding: string;
40 /** Mime type of the file */
41 mimetype: string;
42 /** Size of the file in bytes */
43 size: number;
44 /** The folder to which the file has been saved (DiskStorage) */
45 destination: string;
46 /** The name of the file within the destination (DiskStorage) */
47 filename: string;
48 /** Location of the uploaded file (DiskStorage) */
49 path: string;
50 /** A Buffer of the entire file (MemoryStorage) */
51 buffer: Buffer;
52 }, callback: (error: Error | null, acceptFile: boolean) => void): void;
53}
54/**
55 * @publicApi
56 */
57export interface MulterField {
58 /** The field name. */
59 name: string;
60 /** Optional maximum number of files per field to accept. */
61 maxCount?: number;
62}