UNPKG

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