oh it will get posted to HTTP node, but before that the file needs to save to disk, unless it doesnt have to, but for sure the content of the file isnt what its meant to be.
and then once its written the file to disk i can then post it to my site as part of the rest of the flow
But i have got it to work in this flow but it doesn’t iterate, its just one file in and one out
{
"name": "Upload Image to Wordpress Workflow TEMPLATE",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"functionCode": "const company_logo = items[0].json.company_logo\n\nconst regex = /(base64[^\"]+)/gmi;\n\nconst matched = company_logo.match(regex);\n\nreturn [\n {\n json: {\n company_logo: matched.toString().split(',')[1]\n }\n }\n]\n"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
630,
300
]
},
{
"parameters": {
"fileName": "/files/victim-test.png"
},
"name": "Write Binary File",
"type": "n8n-nodes-base.writeBinaryFile",
"typeVersion": 1,
"position": [
1000,
300
]
},
{
"parameters": {
"functionCode": "return [\n {\n json: {\n \n },\n binary: {\n data: {\n data: $node['Function'].json.company_logo,\n mimeType: \"image/png\",\n fileExtension: 'png',\n fileName: $node[\"Set\"].json[\"name\"]+\".png\"\n }\n }\n }\n]\n"
},
"name": "Function1",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
800,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "company_logo",
"value": "<img src=\"data:image/png;base64,REPLACE-ME-WITH-VALID-BASE64\" />"
},
{
"name": "name",
"value": "234"
}
]
},
"options": {}
},
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
430,
300
]
},
{
"parameters": {
"authentication": "basicAuth",
"requestMethod": "POST",
"url": "https://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"responseFormat": "file",
"jsonParameters": true,
"options": {
"bodyContentType": "multipart-form-data",
"bodyContentCustomMimeType": "image/png"
},
"sendBinaryData": true
},
"name": "WordPress Upload Media",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
1230,
300
],
"executeOnce": false,
"credentials": {
"httpBasicAuth": "xxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
],
"connections": {
"Function": {
"main": [
[
{
"node": "Function1",
"type": "main",
"index": 0
}
]
]
},
"Function1": {
"main": [
[
{
"node": "Write Binary File",
"type": "main",
"index": 0
}
]
]
},
"Set": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
},
"Write Binary File": {
"main": [
[
{
"node": "WordPress Upload Media",
"type": "main",
"index": 0
}
]
]
},
"Start": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {},
"id": 32
}