turns out it was deprecated... BRUH

This commit is contained in:
hippoz 2020-10-02 23:08:12 +03:00
parent 1102ff0ef8
commit 1c1ab074ce

View file

@ -87,14 +87,16 @@ app.post('/api/upload', (req, res) => {
const file = req.files.file;
const filepath = `${config.storagePath}/${file.name}`;
fs.exists(filepath, (exists) => {
if (!exists) {
fs.stat(filepath, (err) => {
if(err == null) {
return res.status(400).send('File exists.');
} else if(err.code === 'ENOENT') {
file.mv(filepath, (err) => {
if (err) return res.status(500).send(err);
res.render('uploaded', { file: { name: file.name } });
});
} else {
return res.status(400).send('File exists.');
return res.sendStatus(500);
}
});
});