delete old file if existing

This commit is contained in:
daniel-j
2020-03-04 13:41:38 +01:00
parent 3fa1341aaf
commit a592adf834

View File

@@ -178,6 +178,12 @@ router.post('/upload', upload.single('file'), async ctx => {
expireKey(key) expireKey(key)
const info = ctx.keys.get(key) const info = ctx.keys.get(key)
if (info.file && info.file.path) {
await new Promise((resolve, reject) => fs.unlink(info.file.path, (err) => {
if (err) reject(err)
resolve()
}))
}
info.file = { info.file = {
name: filename, name: filename,
path: data, path: data,