diff --git a/app/api/files/uploadMiddleware.ts b/app/api/files/uploadMiddleware.ts index 3daa1d69b1..5c0f295479 100644 --- a/app/api/files/uploadMiddleware.ts +++ b/app/api/files/uploadMiddleware.ts @@ -7,7 +7,9 @@ import { promisify } from 'util'; type multerCallback = (error: Error | null, destination: string) => void; -const rename = promisify(fs.rename); +const copyFile = promisify(fs.copyFile); +const removeFile = promisify(fs.unlink); + const defaultStorage = multer.diskStorage({ filename(_req: Request, file: Express.Multer.File, cb: multerCallback) { cb(null, generateFileName(file)); @@ -17,7 +19,8 @@ const defaultStorage = multer.diskStorage({ const move = async (req: Request, filePath: pathFunction) => { const oldPath = path.join(req.file.destination, req.file.filename); const newPath = filePath(req.file.filename); - await rename(oldPath, newPath); + await copyFile(oldPath, newPath); + await removeFile(oldPath); req.file.destination = filePath(); req.file.path = filePath(req.file.filename); }; diff --git a/package.json b/package.json index 67a209c230..c688fc1711 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uwazi", - "version": "1.7.0", + "version": "1.7.1", "description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.", "main": "server.js", "repository": {