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

Function containsBase64File

packages/server/src/utils/fileRepository.ts:7–49  ·  view source on GitHub ↗
(chatflow: ChatFlow)

Source from the content-addressed store, hash-verified

5import { UsageCacheManager } from '../UsageCacheManager'
6
7export const containsBase64File = (chatflow: ChatFlow) => {
8 const parsedFlowData: IReactFlowObject = JSON.parse(chatflow.flowData)
9 const re = new RegExp('^data.*;base64', 'i')
10 let found = false
11 const nodes = parsedFlowData.nodes
12 for (const node of nodes) {
13 if (node.data.category !== 'Document Loaders') {
14 continue
15 }
16 const inputs = node.data.inputs
17 if (inputs) {
18 const keys = Object.getOwnPropertyNames(inputs)
19 for (let i = 0; i < keys.length; i++) {
20 const input = inputs[keys[i]]
21 if (!input) {
22 continue
23 }
24 if (typeof input !== 'string') {
25 continue
26 }
27 if (input.startsWith('[')) {
28 try {
29 const files = JSON.parse(input)
30 for (let j = 0; j < files.length; j++) {
31 const file = files[j]
32 if (re.test(file)) {
33 found = true
34 break
35 }
36 }
37 } catch (e) {
38 continue
39 }
40 }
41 if (re.test(input)) {
42 found = true
43 break
44 }
45 }
46 }
47 }
48 return found
49}
50
51export const updateFlowDataWithFilePaths = async (
52 chatflowid: string,

Callers 2

saveChatflowFunction · 0.90
updateChatflowFunction · 0.90

Calls 2

testMethod · 0.80
parseMethod · 0.65

Tested by

no test coverage detected