{"updatedAt":"2026-01-12T19:35:00.177Z","createdAt":"2026-01-12T19:31:39.960Z","id":"9C97Kn1ZlyyYhjayZin46","name":"NewDemo","active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"NewDemo","responseMode":"responseNode","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"9bb76716-d0bc-424b-bbbe-0d5426ccb78a","name":"Webhook","webhookId":"e87bfa91-2686-43ca-8ff4-68fa7debb4c9"},{"parameters":{"respondWith":"allIncomingItems","options":{}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1008,160],"id":"dc14e923-0bcc-4809-98f7-ed0b22ff136d","name":"Respond to Webhook"},{"parameters":{"jsCode":"const data = $json.body || $json;  // in case webhook wrapped it under \"body\"\n\nconst startISO = data.startISO || data.start || $json.startISO || $json.start;\nconst endISO   = data.endISO   || data.end   || $json.endISO   || $json.end;\n\nreturn {\n  startISO,\n  endISO,\n  startEpoch: startISO ? Math.floor(new Date(startISO).getTime() / 1000) : null,\n  endEpoch: endISO ? Math.floor(new Date(endISO).getTime() / 1000) : null\n};\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[144,144],"id":"f9238d7a-2352-4f93-b4d5-419cd6fec896","name":"Code in JavaScript"},{"parameters":{"jsCode":"const raw = $json.stdout || \"\";\nconst root = \"/mnt/data/PublicFiles/data/\";\nconst baseUrl = \"https://min.velvetcld.gleeze.com/data\";\n\n// Keep only the lines that actually contain file paths\nconst lines = raw\n  .split(\"\\n\")\n  .filter(line => line.includes(root));\n\n// Turn each line into a JSON item\nconst items = lines.map(line => {\n  // line = \"2025-11-06T10:31:13 /mnt/data/PublicFiles/data/20251106_130340.jpg\"\n  const firstSpace = line.indexOf(\" \");\n  const path = line.slice(firstSpace + 1).trim();       // \"/mnt/data/.../20251106_130340.jpg\"\n  const rel = path.replace(root, \"\");                  // \"20251106_130340.jpg\" (or subdir/file.ext)\n  const name = rel.split(\"/\").pop();                   // just the file name\n\n  // Build public URL for the thumbnail\n  const encodedRel = rel\n    .split(\"/\")\n    .map(encodeURIComponent)\n    .join(\"/\");\n  const url = `${baseUrl}/${encodedRel}`;\n\n  return {\n    name,   // just the filename (what you asked to see)\n    url     // public URL you can use as <img src=\"...\">\n  };\n});\n\nreturn items;\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[560,160],"id":"2d17a135-272a-445a-9955-5cb381e7b570","name":"Parse Files"},{"parameters":{"jsCode":"// Collect all file items from \"Parse Files\"\nconst files = $items(\"Parse Files\").map(item => item.json);\n\n// Return a SINGLE item that wraps them\nreturn [\n  {\n    files\n  }\n];\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[768,160],"id":"741a86a4-5a9d-49a9-a66c-88c6ab259d58","name":"Wrap For Response"},{"parameters":{"jsCode":"const fs = require('fs');\nconst path = require('path');\n\nconst rootDir = '/mnt/data/PublicFiles/data';\n\n// Inputs produced by \"Code in JavaScript\"\nconst startEpoch = Number($json.startEpoch);\nconst endEpoch = Number($json.endEpoch);\n\nif (!Number.isFinite(startEpoch) || !Number.isFinite(endEpoch)) {\n  throw new Error('Missing/invalid startEpoch or endEpoch. Send startISO/endISO (or start/end) to the webhook.');\n}\n\nconst entries = fs.readdirSync(rootDir, { withFileTypes: true });\n\nconst results = [];\n\nfor (const entry of entries) {\n  if (!entry.isFile()) continue;\n\n  const fullPath = path.join(rootDir, entry.name);\n\n  let st;\n  try {\n    st = fs.statSync(fullPath);\n  } catch (e) {\n    continue; // skip unreadable files\n  }\n\n  const mtimeEpoch = Math.floor(st.mtimeMs / 1000);\n\n  if (mtimeEpoch >= startEpoch && mtimeEpoch <= endEpoch) {\n    // Match the old Execute Command output style so your \"Parse Files\" node keeps working\n    const iso = new Date(mtimeEpoch * 1000).toISOString().slice(0, 19); // YYYY-MM-DDTHH:MM:SS\n    results.push({ json: { stdoutLine: `${iso} ${fullPath}` } });\n  }\n}\n\n// To preserve your existing \"Parse Files\" logic (which reads $json.stdout),\n// we output ONE item with stdout as multi-line text, like Execute Command did.\nconst stdout = results.map(r => r.json.stdoutLine).join('\\n');\nreturn [{ json: { stdout } }];\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[352,144],"id":"d688fe89-e54c-4aee-b9e2-68219e91579b","name":"List Files (mtime filter)"}],"connections":{"Code in JavaScript":{"main":[[{"node":"List Files (mtime filter)","type":"main","index":0}]]},"Parse Files":{"main":[[{"node":"Wrap For Response","type":"main","index":0}]]},"Wrap For Response":{"main":[[{"node":"Respond to Webhook","type":"main","index":0}]]},"List Files (mtime filter)":{"main":[[{"node":"Parse Files","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Code in JavaScript","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","availableInMCP":false},"staticData":null,"meta":null,"pinData":{},"versionId":"7728445d-8529-4a2f-94f6-0aeadf6fe248","activeVersionId":"7728445d-8529-4a2f-94f6-0aeadf6fe248","triggerCount":1,"shared":[{"updatedAt":"2026-01-12T19:31:39.962Z","createdAt":"2026-01-12T19:31:39.962Z","role":"workflow:owner","workflowId":"9C97Kn1ZlyyYhjayZin46","projectId":"lh2csO3ZG7MzpN8o"}],"activeVersion":{"updatedAt":"2026-01-12T19:35:52.000Z","createdAt":"2026-01-12T19:35:00.178Z","versionId":"7728445d-8529-4a2f-94f6-0aeadf6fe248","workflowId":"9C97Kn1ZlyyYhjayZin46","nodes":[{"parameters":{"httpMethod":"POST","path":"NewDemo","responseMode":"responseNode","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"9bb76716-d0bc-424b-bbbe-0d5426ccb78a","name":"Webhook","webhookId":"e87bfa91-2686-43ca-8ff4-68fa7debb4c9"},{"parameters":{"respondWith":"allIncomingItems","options":{}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[1008,160],"id":"dc14e923-0bcc-4809-98f7-ed0b22ff136d","name":"Respond to Webhook"},{"parameters":{"jsCode":"const data = $json.body || $json;  // in case webhook wrapped it under \"body\"\n\nconst startISO = data.startISO || data.start || $json.startISO || $json.start;\nconst endISO   = data.endISO   || data.end   || $json.endISO   || $json.end;\n\nreturn {\n  startISO,\n  endISO,\n  startEpoch: startISO ? Math.floor(new Date(startISO).getTime() / 1000) : null,\n  endEpoch: endISO ? Math.floor(new Date(endISO).getTime() / 1000) : null\n};\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[144,144],"id":"f9238d7a-2352-4f93-b4d5-419cd6fec896","name":"Code in JavaScript"},{"parameters":{"jsCode":"const raw = $json.stdout || \"\";\nconst root = \"/mnt/data/PublicFiles/data/\";\nconst baseUrl = \"https://min.velvetcld.gleeze.com/data\";\n\n// Keep only the lines that actually contain file paths\nconst lines = raw\n  .split(\"\\n\")\n  .filter(line => line.includes(root));\n\n// Turn each line into a JSON item\nconst items = lines.map(line => {\n  // line = \"2025-11-06T10:31:13 /mnt/data/PublicFiles/data/20251106_130340.jpg\"\n  const firstSpace = line.indexOf(\" \");\n  const path = line.slice(firstSpace + 1).trim();       // \"/mnt/data/.../20251106_130340.jpg\"\n  const rel = path.replace(root, \"\");                  // \"20251106_130340.jpg\" (or subdir/file.ext)\n  const name = rel.split(\"/\").pop();                   // just the file name\n\n  // Build public URL for the thumbnail\n  const encodedRel = rel\n    .split(\"/\")\n    .map(encodeURIComponent)\n    .join(\"/\");\n  const url = `${baseUrl}/${encodedRel}`;\n\n  return {\n    name,   // just the filename (what you asked to see)\n    url     // public URL you can use as <img src=\"...\">\n  };\n});\n\nreturn items;\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[560,160],"id":"2d17a135-272a-445a-9955-5cb381e7b570","name":"Parse Files"},{"parameters":{"jsCode":"// Collect all file items from \"Parse Files\"\nconst files = $items(\"Parse Files\").map(item => item.json);\n\n// Return a SINGLE item that wraps them\nreturn [\n  {\n    files\n  }\n];\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[768,160],"id":"741a86a4-5a9d-49a9-a66c-88c6ab259d58","name":"Wrap For Response"},{"parameters":{"jsCode":"const fs = require('fs');\nconst path = require('path');\n\nconst rootDir = '/mnt/data/PublicFiles/data';\n\n// Inputs produced by \"Code in JavaScript\"\nconst startEpoch = Number($json.startEpoch);\nconst endEpoch = Number($json.endEpoch);\n\nif (!Number.isFinite(startEpoch) || !Number.isFinite(endEpoch)) {\n  throw new Error('Missing/invalid startEpoch or endEpoch. Send startISO/endISO (or start/end) to the webhook.');\n}\n\nconst entries = fs.readdirSync(rootDir, { withFileTypes: true });\n\nconst results = [];\n\nfor (const entry of entries) {\n  if (!entry.isFile()) continue;\n\n  const fullPath = path.join(rootDir, entry.name);\n\n  let st;\n  try {\n    st = fs.statSync(fullPath);\n  } catch (e) {\n    continue; // skip unreadable files\n  }\n\n  const mtimeEpoch = Math.floor(st.mtimeMs / 1000);\n\n  if (mtimeEpoch >= startEpoch && mtimeEpoch <= endEpoch) {\n    // Match the old Execute Command output style so your \"Parse Files\" node keeps working\n    const iso = new Date(mtimeEpoch * 1000).toISOString().slice(0, 19); // YYYY-MM-DDTHH:MM:SS\n    results.push({ json: { stdoutLine: `${iso} ${fullPath}` } });\n  }\n}\n\n// To preserve your existing \"Parse Files\" logic (which reads $json.stdout),\n// we output ONE item with stdout as multi-line text, like Execute Command did.\nconst stdout = results.map(r => r.json.stdoutLine).join('\\n');\nreturn [{ json: { stdout } }];\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[352,144],"id":"d688fe89-e54c-4aee-b9e2-68219e91579b","name":"List Files (mtime filter)"}],"connections":{"Code in JavaScript":{"main":[[{"node":"List Files (mtime filter)","type":"main","index":0}]]},"Parse Files":{"main":[[{"node":"Wrap For Response","type":"main","index":0}]]},"Wrap For Response":{"main":[[{"node":"Respond to Webhook","type":"main","index":0}]]},"List Files (mtime filter)":{"main":[[{"node":"Parse Files","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Code in JavaScript","type":"main","index":0}]]}},"authors":"Ben Hex","name":"Version 7728445d","description":"","autosaved":false},"tags":[]}