tachybase_todo/packages/plugin-file-manager/src/utils.ts

9 lines
251 B
TypeScript
Raw Normal View History

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)}`)
})
}