add: upload file
This commit is contained in:
12
src/helper/file-handler.ts
Normal file
12
src/helper/file-handler.ts
Normal 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}`);
|
||||
};
|
||||
Reference in New Issue
Block a user