multer-hash
upload file save as hash that wraps around multer,the file name will also with height and width if is image
Installation
npm install multer-hash
Usage
const multerHash = ;const app = ;const uploader = app
config
same as multer:
- dest
- limits
- field(default as Filedata)
fileFilter
same as multer,also support file extension array
{
fileFilter:['jpg','png']
}
cachePath
a cachePath for save file to calculate file hash and image size,will choose system cache path if not specify
result handling
get file path with hashed name in req.publicPath
const multerHash = ;const uploader =
error handling
specify error code:
ERROR_CODE = 'IO': 'IO' 'INVALID_IMAGE': 'INVALID_IMAGE' 'LIMIT_FILE_SIZE': 'LIMIT_FILE_SIZE' 'LIMIT_UNEXPECTED_FILE': 'LIMIT_UNEXPECTED_FILE' 'UNKNOWN': 'UNKNOWN'
exmaple
const multerHash = ;const ERROR_CODE = multerHashERROR_CODE;const uploader =