1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-07 22:50:05 +00:00

fix: improvement in flow of uploading

This commit is contained in:
Saad Jutt
2022-02-28 22:12:39 +05:00
parent 765969db11
commit 8c1941a87b
3 changed files with 16 additions and 6 deletions

View File

@@ -214,18 +214,15 @@ const saveFile = async (
.replace(new RegExp('/', 'g'), path.sep)
if (!filePathFull.includes(driveFilesPath)) {
await deleteFile(multerFile.path)
throw new Error('Cannot put file outside drive.')
}
if (await fileExists(filePathFull)) {
await deleteFile(multerFile.path)
throw new Error('File already exists.')
}
const folderPath = path.dirname(filePathFull)
await createFolder(folderPath)
await moveFile(multerFile.path, filePathFull)
return { status: 'success' }