{
  "name": "NATS Object Store File Handling",
  "nodes": [
    {
      "parameters": {},
      "id": "start",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "resource": "bucket",
        "operation": "create",
        "bucket": "documents",
        "config": {
          "description": "Document storage bucket",
          "storage": "file",
          "replicas": 1
        }
      },
      "id": "create-bucket",
      "name": "Create Document Bucket",
      "type": "n8n-nodes-synadia.natsObjectStore",
      "typeVersion": 1,
      "position": [
        460,
        200
      ],
      "credentials": {
        "natsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "content",
              "value": "={{\"# Sample Report\\n\\nThis is a sample report generated at \" + $now.toISO() + \"\\n\\n## Summary\\n- Total items: 42\\n- Status: Completed\\n- Generated by: n8n workflow\"}}"
            }
          ]
        },
        "config": {}
      },
      "id": "create-content",
      "name": "Create Report Content",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        460,
        400
      ]
    },
    {
      "parameters": {
        "resource": "object",
        "operation": "put",
        "bucket": "documents",
        "name": "={{\"reports/2024/\" + $now.format('yyyy-MM-dd') + \"-daily-report.md\"}}",
        "data": "={{$json.content}}",
        "config": {
          "dataType": "string",
          "description": "Daily report"
        }
      },
      "id": "store-file",
      "name": "Store Report",
      "type": "n8n-nodes-synadia.natsObjectStore",
      "typeVersion": 1,
      "position": [
        680,
        400
      ],
      "credentials": {
        "natsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "object",
        "operation": "list",
        "bucket": "documents",
        "config": {}
      },
      "id": "list-files",
      "name": "List All Files",
      "type": "n8n-nodes-synadia.natsObjectStore",
      "typeVersion": 1,
      "position": [
        900,
        300
      ],
      "credentials": {
        "natsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fieldToSplitOut": "objects",
        "options": {}
      },
      "id": "split-files",
      "name": "Split File List",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "resource": "object",
        "operation": "info",
        "bucket": "documents",
        "name": "={{$json.name}}",
        "config": {}
      },
      "id": "get-info",
      "name": "Get File Info",
      "type": "n8n-nodes-synadia.natsObjectStore",
      "typeVersion": 1,
      "position": [
        1320,
        300
      ],
      "credentials": {
        "natsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "bucket": "documents",
        "options": {
          "nameFilter": "reports/2024/*",
          "includeDeletes": true,
          "includeHistory": false
        }
      },
      "id": "watch-files",
      "name": "Watch for File Changes",
      "type": "n8n-nodes-synadia.natsObjectStoreTrigger",
      "typeVersion": 1,
      "position": [
        460,
        600
      ],
      "credentials": {
        "natsApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "object",
        "operation": "get",
        "bucket": "documents",
        "name": "={{$json.name}}",
        "config": {}
      },
      "id": "get-latest-file",
      "name": "Get Latest File Content",
      "type": "n8n-nodes-synadia.natsObjectStore",
      "typeVersion": 1,
      "position": [
        680,
        600
      ],
      "credentials": {
        "natsApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Create Document Bucket",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Report Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Report Content": {
      "main": [
        [
          {
            "node": "Store Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Report": {
      "main": [
        [
          {
            "node": "List All Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List All Files": {
      "main": [
        [
          {
            "node": "Split File List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split File List": {
      "main": [
        [
          {
            "node": "Get File Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Watch for File Changes": {
      "main": [
        [
          {
            "node": "Get Latest File Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "versionId": "object-store-v1",
  "id": "5",
  "tags": [
    "nats",
    "object-store",
    "files",
    "example"
  ]
}