tachybase_todo/packages/plugin-file-manager/src/utils.ts
2021-03-28 13:34:51 +08:00

9 lines
250 B
TypeScript

import crypto from 'crypto';
import path from 'path';
export function getFilename(req, file, cb) {
crypto.pseudoRandomBytes(16, function (err, raw) {
cb(err, err ? undefined : `${raw.toString('hex')}${path.extname(file.originalname)}`)
})
}