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:
@@ -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' }
|
||||
|
||||
Reference in New Issue
Block a user