{
  "name": "Nextcloud - get photo",
  "nodes": [
    {
      "parameters": {
        "path": "nextcloud-get",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -224,
        -96
      ],
      "id": "918dcb8b-c9c7-4697-b625-f2b7a98262d4",
      "name": "Webhook",
      "webhookId": "b4eece84-830f-4d06-b0ce-5f632329443e"
    },
    {
      "parameters": {
        "respondWith": "binary",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        1552,
        -128
      ],
      "id": "a9534472-01ee-4ba7-ac88-227fc5eace9b",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "url": "=NEXTCLOUD_BASE_URL/PRINCIPAL_USERNAME/Photos/{{ $json.query.path }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "file.jpeg"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        144,
        -336
      ],
      "id": "ce2943a8-ede6-48f6-81a6-5a2599f31f74",
      "name": "HTTP Request",
      "credentials": {
        "httpBasicAuth": {
          "id": "Z91lgaMDXt1ydvqq",
          "name": "Nextcloud"
        }
      }
    },
    {
      "parameters": {
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "original"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $('Webhook').item.json.query.path }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "value": "={{ $json.data }}",
            "size": "original",
            "key": "={{ $('Webhook').item.json.query.path }}",
            "type": "favorite"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "type",
              "displayName": "type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "size",
              "displayName": "size",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "key",
              "displayName": "key",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "value",
              "displayName": "value",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        432,
        -336
      ],
      "id": "65bba69e-711c-4f42-8551-cbead15710cd",
      "name": "Upsert row(s)"
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "binaryPropertyName": "=file.jpeg",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        288,
        -336
      ],
      "id": "9a91b4b6-f7f2-442b-829f-40e6df82f4a3",
      "name": "Extract from File"
    },
    {
      "parameters": {
        "operation": "rowNotExists",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "original"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $json.query.path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        0,
        -336
      ],
      "id": "242ca98f-a7a0-4b65-823e-d0f707500b9c",
      "name": "If original not exist"
    },
    {
      "parameters": {
        "operation": "rowExists",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "original"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $json.query.path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        160,
        -96
      ],
      "id": "c9be3c65-7159-4ec2-adda-13899504dffe",
      "name": "If original exists"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        496,
        -112
      ],
      "id": "b8aa35e6-8259-4924-9a2f-cef04d28fbc9",
      "name": "Merge"
    },
    {
      "parameters": {
        "operation": "rowExists",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "thumb"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $json.query.path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        816,
        -112
      ],
      "id": "998a90ec-5955-42f2-9cdb-64d7ffe100df",
      "name": "If thumb exists"
    },
    {
      "parameters": {
        "operation": "rowNotExists",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "thumb"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $json.query.path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        688,
        -336
      ],
      "id": "cfa106dc-0548-4838-ac64-e0b46815bcb1",
      "name": "If thumb not exist"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1104,
        -128
      ],
      "id": "428c33e7-6ecf-4f93-a6ee-6421dae04d6e",
      "name": "Merge1"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "={{ $('Webhook').item.json.query.size || \"original\" }}"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $('Webhook').item.json.query.path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1248,
        -128
      ],
      "id": "b4fe5d2d-80fb-41b6-a44b-225d4e356e7e",
      "name": "Get row(s)"
    },
    {
      "parameters": {
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "thumb"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $('Webhook').item.json.query.path }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "value": "={{ $json.data }}",
            "size": "thumb",
            "key": "={{ $('Webhook').item.json.query.path }}",
            "type": "favorite"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "type",
              "displayName": "type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "size",
              "displayName": "size",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "key",
              "displayName": "key",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "value",
              "displayName": "value",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1408,
        -336
      ],
      "id": "2dc7f651-1a7f-4eaf-beec-04452ecf58d1",
      "name": "Upsert row(s)1"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "Bra0wmRfWsSApVka",
          "mode": "list",
          "cachedResultName": "nextcloud - cache",
          "cachedResultUrl": "/projects/Lc8zYWu0rH8w8eDs/datatables/Bra0wmRfWsSApVka"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "type",
              "keyValue": "favorite"
            },
            {
              "keyName": "size",
              "keyValue": "original"
            },
            {
              "keyName": "key",
              "keyValue": "={{ $('Webhook').item.json.query.path }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        832,
        -336
      ],
      "id": "57bb6e65-63e0-4c23-983a-5030ca48d061",
      "name": "Get row(s)1"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "value",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        976,
        -336
      ],
      "id": "6df7d68b-d56d-41ea-97ce-bbad8ec0631d",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        1264,
        -336
      ],
      "id": "fce28cb8-e27f-40e9-b74e-1ac1d0141e55",
      "name": "Extract from File1"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "value",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1392,
        -128
      ],
      "id": "93914a27-47cf-4a7c-968d-d71f351d58b2",
      "name": "Convert to File1"
    },
    {
      "parameters": {
        "content": "## Resize",
        "height": 240,
        "width": 160
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -400
      ],
      "typeVersion": 1,
      "id": "9f6d0e31-17d9-4f92-b367-340bd90441f0",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "operation": "resize",
        "width": 1000,
        "height": 1000,
        "resizeOption": "onlyIfLarger",
        "options": {}
      },
      "type": "n8n-nodes-base.editImage",
      "typeVersion": 1,
      "position": [
        1120,
        -336
      ],
      "id": "c253e1f6-85a3-41c5-b8ff-aef7ea6579c0",
      "name": "Edit Image"
    },
    {
      "parameters": {
        "content": "## Fetch from Nextcloud",
        "height": 240,
        "width": 160
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        -416
      ],
      "typeVersion": 1,
      "id": "44c7f051-65e2-457c-8bf9-f926a167d96c",
      "name": "Sticky Note1"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "If original not exist",
            "type": "main",
            "index": 0
          },
          {
            "node": "If original exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert row(s)": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Upsert row(s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If original not exist": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If original exists": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "If thumb exists",
            "type": "main",
            "index": 0
          },
          {
            "node": "If thumb not exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If thumb exists": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "If thumb not exist": {
      "main": [
        [
          {
            "node": "Get row(s)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Get row(s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s)": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert row(s)1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s)1": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Edit Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File1": {
      "main": [
        [
          {
            "node": "Upsert row(s)1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Image": {
      "main": [
        [
          {
            "node": "Extract from File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "83ef3531-b9e6-4d1b-be6e-8e877934d3c6",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "c744a803fbee0d2a2159403787f35ebac356b936840a6ed99b40231bb88d9690"
  },
  "id": "Ug67ndarr2XkGSWw",
  "tags": []
}