fixed docker deployment

This commit is contained in:
2025-01-25 17:09:44 +03:00
parent b82c2dc1d6
commit a1890acad0
5 changed files with 24 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ const handlePostData = async (req: Request, res: Response, next: NextFunction):
if (postToUpdate.type == 1) {
const filename = postToUpdate.message;
fs.rmSync(`${process.env.UPLOAD_DESTINATION}/${filename}`);
fs.unlinkSync(`${process.env.UPLOAD_DESTINATION}/${filename}`);
}
}
if (req.file) {
@@ -33,9 +33,10 @@ const handlePostData = async (req: Request, res: Response, next: NextFunction):
const hash = crypto.createHash('md5');
hash.update(buffer);
const newFilename = `${hash.digest('hex')}${extension}`;
fs.renameSync(`./${req.file.path}`, `${process.env.UPLOAD_DESTINATION}/${newFilename}`)
post.message = newFilename
post.type = 1
fs.copyFileSync(`./${req.file.path}`, `${process.env.UPLOAD_DESTINATION}/${newFilename}`);
fs.unlinkSync(`./${req.file.path}`);
post.message = newFilename;
post.type = 1;
} else {
post.type = 0;
post.message = message;