2020-12-31 12:11:38 +08:00
|
|
|
import crypto from 'crypto';
|
|
|
|
import path from 'path';
|
|
|
|
|
2021-03-28 13:34:51 +08:00
|
|
|
export function getFilename(req, file, cb) {
|
2020-12-31 12:11:38 +08:00
|
|
|
crypto.pseudoRandomBytes(16, function (err, raw) {
|
|
|
|
cb(err, err ? undefined : `${raw.toString('hex')}${path.extname(file.originalname)}`)
|
|
|
|
})
|
|
|
|
}
|