v2.3
This commit is contained in:
@@ -99,7 +99,7 @@ async function addFilePathToJson(filePath) {
|
||||
if (await fsExtra.pathExists(jsonFilePath)) {
|
||||
await lockFile(jsonFilePath);
|
||||
data = await fsExtra.readJson(jsonFilePath);
|
||||
}else{
|
||||
} else {
|
||||
await lockFile(jsonFilePath);
|
||||
}
|
||||
|
||||
@@ -160,10 +160,10 @@ app.post('/upload', (req, res) => {
|
||||
await fsExtra.move(req.file.path, finalPath, { overwrite: true });
|
||||
await addFilePathToJson(finalPath);
|
||||
|
||||
res.status(httpStatus.OK).json({message: 'Upload successful.'})
|
||||
res.status(httpStatus.OK).json({ message: 'Upload successful.' });
|
||||
} catch (error) {
|
||||
console.error('Failed to move file:', error);
|
||||
res.status(httpStatus.INTERNAL_SERVER_ERROR).json({message: 'Server error while moving the file.'});
|
||||
res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ message: 'Server error while moving the file.' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user