4.0.0 • Published 8 months ago
multer-media v4.0.0
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 |
4.0.0
8 months ago
3.3.1
1 year ago
3.2.1
2 years ago
3.2.0
2 years ago
3.1.10
3 years ago
3.1.9
3 years ago
3.1.8
3 years ago
3.1.3
3 years ago
3.1.7
3 years ago
3.1.6
3 years ago
3.1.5
3 years ago
3.1.4
3 years ago
3.1.2
3 years ago
3.1.1
3 years ago
3.1.0
3 years ago
3.0.0
3 years ago
2.1.2
3 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.12
4 years ago
2.0.11
4 years ago
2.0.10
4 years ago
2.0.9
4 years ago
2.0.8
4 years ago
2.0.7
4 years ago
2.0.6
4 years ago
2.0.5
4 years ago
2.0.4
4 years ago
2.0.3
4 years ago
2.0.2
4 years ago
2.0.1
4 years ago
2.0.0
4 years ago
1.3.0
4 years ago
1.2.0
4 years ago
1.1.0
4 years ago
1.0.0
4 years ago
0.0.8
4 years ago
0.0.7
4 years ago
0.0.6
4 years ago
0.0.5
4 years ago
0.0.4
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago