3.2.1 • Published 9 months ago
multer-media v3.2.1
Multer media
Installation
$ yarn add multer-media
Usage
const upload = multer({
storage: multerMedia({
algorithm: 'md5',
destination: (
req: ExpressRequest,
file: Express.Multer.File,
callback: (error: Error | null, path: string) => void,
) => {
callback(null, '/tmp/my-uploads');
},
filename: (
req: ExpressRequest,
file: Express.Multer.File,
callback: (error: Error | null, path: string) => void,
) => {
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9)
callback(null, file.fieldname + '-' + uniqueSuffix);
},
/**
* A function that will be executed on start
*
* @param req The Express `Request` object.
* @param file Object containing information about the processed file.
* @param src Stream Readable
*/
start?: (
req: Request,
file: Express.Multer.File,
outStream?: stream.Writable,
chunk?: any,
encoding?: BufferEncoding,
) => {},
/**
* A function that will be executed on write events
*
* @param req The Express `Request` object.
* @param file Object containing information about the processed file.
* @param src Stream Readable
*/
write?: (
req: Request,
file: Express.Multer.File,
outStream?: stream.Writable,
chunk?: any,
encoding?: BufferEncoding,
) => {},
/**
* A function that will be executed on write events
*
* @param req The Express `Request` object.
* @param file Object containing information about the processed file.
* @param src Stream Readable
*/
finish?: (
req: Request,
file: Express.Multer.File,
outStream?: stream.Writable,
chunk?: any,
encoding?: BufferEncoding,
) => {},
}),
});
API
File information
Each file contains the following information:
Key | Type | Description |
---|---|---|
fieldname | string | Field name specified in the form |
originalname | string | Name of the file on the user's computer |
encoding | string | Encoding type of the file |
mimetype | string | Mime type of the file |
size | number | Size of the file in bytes |
destination | string | The folder to which the file has been saved |
filename | string | The name of the file within the destination |
path | string | The full path to the uploaded file |
hash | string | Hash with algorithm the file |
media | FfprobeData | Media probe of this file, using ffmpeg-static |
3.2.1
9 months ago
3.2.0
9 months ago
3.1.10
2 years ago
3.1.9
2 years ago
3.1.8
2 years ago
3.1.3
2 years ago
3.1.7
2 years ago
3.1.6
2 years ago
3.1.5
2 years ago
3.1.4
2 years ago
3.1.2
2 years ago
3.1.1
2 years ago
3.1.0
2 years ago
3.0.0
2 years ago
2.1.2
2 years ago
2.1.1
2 years ago
2.1.0
2 years ago
2.0.12
2 years ago
2.0.11
2 years ago
2.0.10
2 years ago
2.0.9
2 years ago
2.0.8
2 years ago
2.0.7
2 years ago
2.0.6
2 years ago
2.0.5
2 years ago
2.0.4
2 years ago
2.0.3
2 years ago
2.0.2
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.3.0
2 years ago
1.2.0
2 years ago
1.1.0
2 years ago
1.0.0
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago