fix: Overwriting assert with the same name

This commit is contained in:
NaturalBase 2022-10-12 22:34:13 +08:00 committed by GitHub
parent cf7abeaa94
commit 192a28c6ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,7 +76,8 @@ router.post('/u', (req, res, next) => {
}
// Sanitize filename
fileMeta.originalname = sanitize(fileMeta.originalname.toLowerCase().replace(/[\s,;#]+/g, '_'))
let time = new Date().getTime()
fileMeta.originalname = req.user.name + "_" + time + "_" + sanitize(fileMeta.originalname.toLowerCase().replace(/[\s,;#]+/g, '_'))
// Check if user can upload at path
const assetPath = (folderId) ? hierarchy.map(h => h.slug).join('/') + `/${fileMeta.originalname}` : fileMeta.originalname