Fix a problem when implement the _handleFile

When implementing the `StorageEngine`, I did have to implement `_handleFile` & `_removeFile`.
But it had a problem. When I call the `callback` function, I have to specify all fields of the `Express.Multer.File` interface. Actually, it's not required.

So, I add a new interface which named `FileInfo`. It's similar to `Express.Multer.File`, but all fields are optional.
This commit is contained in:
HyunSeob
2017-08-18 15:15:58 +09:00
committed by GitHub
parent 7ad5650b35
commit 315f0031df
+14 -1
View File
@@ -4,6 +4,7 @@
// vilicvane <https://vilic.github.io/>
// David Broder-Rodgers <https://github.com/DavidBR-SW>
// Michael Ledin <https://github.com/mxl>
// HyunSeob Lee <https://github.com/hyunseob>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as express from 'express';
@@ -47,10 +48,22 @@ declare namespace multer {
}
interface StorageEngine {
_handleFile(req: express.Request, file: Express.Multer.File, callback: (error?: any, info?: Express.Multer.File) => void): void;
_handleFile(req: express.Request, file: Express.Multer.File, callback: (error?: any, info?: FileInfo) => void): void;
_removeFile(req: express.Request, file: Express.Multer.File, callback: (error: Error) => void): void;
}
interface FileInfo {
fieldname?: string;
originalname?: string;
encoding?: string;
mimetype?: string;
size?: number;
destination?: string;
filename?: string;
path?: string;
buffer?: Buffer;
}
interface DiskStorageOptions {
/** A function used to determine within which folder the uploaded files should be stored. Defaults to the system's default temporary directory. */
destination?: string | ((req: Express.Request, file: Express.Multer.File, callback: (error: Error | null, destination: string) => void) => void);