3.2.1 • Published 9 months ago

multer-media v3.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

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:

KeyTypeDescription
fieldnamestringField name specified in the form
originalnamestringName of the file on the user's computer
encodingstringEncoding type of the file
mimetypestringMime type of the file
sizenumberSize of the file in bytes
destinationstringThe folder to which the file has been saved
filenamestringThe name of the file within the destination
pathstringThe full path to the uploaded file
hashstringHash with algorithm the file
mediaFfprobeDataMedia 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