Answers for "config multer uploaod image"

0

config multer uploaod image

import multer from 'multer';
import path from 'path';
import crypto from 'crypto';

export default {
    storage: multer.diskStorage({
        destination: path.resolve(__dirname, '..', '..', 'tmp'),
        filename(request, file, callback){
            const fileHash = crypto.randomBytes(10).toString('hex');
            const fileName = `${fileHash}-${file.originalname}`;

            return callback(null, fileName);
        }
    })
}
Posted by: Guest on June-17-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language