delete old file if existing
This commit is contained in:
6
index.js
6
index.js
@@ -178,6 +178,12 @@ router.post('/upload', upload.single('file'), async ctx => {
|
||||
|
||||
expireKey(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 = {
|
||||
name: filename,
|
||||
path: data,
|
||||
|
||||
Reference in New Issue
Block a user