add: upload file

This commit is contained in:
ilham
2021-12-20 14:01:32 +07:00
parent bee8557055
commit 8941184656
7 changed files with 68 additions and 45 deletions

View File

@@ -0,0 +1,12 @@
import * as path from 'path';
export const editFileName = (req, file, callback) => {
const name = file.originalname.split('.')[0];
const fileExtName = path.extname(file.originalname);
// const fileExtName = 'asdasd';
const randomName = Array(4)
.fill(null)
.map(() => Math.round(Math.random() * 16).toString(16))
.join('');
callback(null, `${name}-${randomName}${fileExtName}`);
};