(req: Request, res: Response, next: NextFunction)
| 28 | } |
| 29 | |
| 30 | const deleteFile = async (req: Request, res: Response, next: NextFunction) => { |
| 31 | try { |
| 32 | const activeOrganizationId = req.user?.activeOrganizationId |
| 33 | if (!activeOrganizationId) { |
| 34 | throw new InternalFlowiseError( |
| 35 | StatusCodes.NOT_FOUND, |
| 36 | `Error: filesController.deleteFile - organization ${activeOrganizationId} not found!` |
| 37 | ) |
| 38 | } |
| 39 | const activeWorkspaceId = req.user?.activeWorkspaceId |
| 40 | if (!activeWorkspaceId) { |
| 41 | throw new InternalFlowiseError( |
| 42 | StatusCodes.NOT_FOUND, |
| 43 | `Error: filesController.deleteFile - workspace ${activeWorkspaceId} not found!` |
| 44 | ) |
| 45 | } |
| 46 | const filePath = req.query.path as string |
| 47 | const paths = filePath.split(path.sep).filter((path) => path !== '') |
| 48 | const { totalSize } = await removeSpecificFileFromStorage(activeOrganizationId, ...paths) |
| 49 | await updateStorageUsage(activeOrganizationId, activeWorkspaceId, totalSize, getRunningExpressApp().usageCacheManager) |
| 50 | return res.json({ message: 'file_deleted' }) |
| 51 | } catch (error) { |
| 52 | next(error) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | export default { |
| 57 | getAllFiles, |
nothing calls this directly
no test coverage detected