Hi, i have receive a Binary PDF File from a Server. This works, but the Name of the PDF is wrong, how can i change it ?
Thanks,
Stefan
Hi, i have receive a Binary PDF File from a Server. This works, but the Name of the PDF is wrong, how can i change it ?
Thanks,
Stefan
You can use the function node to change the name. The function node should look like this:
items[0].binary.data.fileName = 'newName.pdf'
return items;
Example workflow below:
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"functionCode": "items[0].binary.data.fileName = 'newName.pdf'\n\nreturn items;"
},
"name": "Function",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
700,
300
],
"notesInFlow": true,
"notes": "change name"
},
{
"parameters": {
"url": "https://www.computerhope.com/jargon/p/example.pdf",
"responseFormat": "file",
"options": {}
},
"name": "HTTP Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [
480,
300
]
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Function",
"type": "main",
"index": 0
}
]
]
}
}
}
Great, i have found it by my self.
items[0].binary.data.fileName = $node['Set File Name'].json["FileName"];
return items;
Thanks, Ricardo