[
{
"id": "c4be0c03394f3820",
"type": "e-mail in",
"z": "8357254d.c82348",
"name": "Labeled \"paperless\"",
"protocol": "IMAP",
"server": "imap.gmail.com",
"useSSL": true,
"port": "993",
"box": "paperless",
"disposition": "Delete",
"criteria": "ALL",
"repeat": "300",
"fetch": "auto",
"inputs": 0,
"credentials": {},
"x": 150,
"y": 1620,
"wires": [
[
"e35b453e84d00cd0"
]
]
},
{
"id": "c2bd3c483e183a98",
"type": "http request",
"z": "8357254d.c82348",
"name": "",
"method": "use",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"credentials": {
"user": "",
"password": ""
},
"x": 850,
"y": 1620,
"wires": [
[]
]
},
{
"id": "e35b453e84d00cd0",
"type": "function",
"z": "8357254d.c82348",
"name": "",
"func": "const url = \"http://your.paperless.host/api/documents/post_document/\";\nconst token = \"xxxxxx\";\n\nconst attachments = msg.attachments;\nif (!attachments) return;\n\nconst createMsg = (attachment => {\n return {\n \"method\": \"POST\",\n \"url\": url,\n \"headers\": {\n \"Authorization\": `Token ${token}`,\n \"Content-Type\": \"multipart/form-data\"\n },\n \"payload\": {\n \"document\": {\n \"value\": attachment.content,\n \"options\": {\n \"filename\": attachment.filename\n }\n }\n }\n } \n})\n\nreturn [attachments.map(createMsg)];\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 1620,
"wires": [
[
"c2bd3c483e183a98"
]
]
}
]