MCPcopy
hub / github.com/FlowiseAI/Flowise / deleteFile

Function deleteFile

packages/server/src/controllers/files/index.ts:30–54  ·  view source on GitHub ↗
(req: Request, res: Response, next: NextFunction)

Source from the content-addressed store, hash-verified

28}
29
30const 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
56export default {
57 getAllFiles,

Callers

nothing calls this directly

Calls 3

updateStorageUsageFunction · 0.90
getRunningExpressAppFunction · 0.90

Tested by

no test coverage detected