@zenofmud I have read the attatchment session on the documentation. And found the attachment "object" im msg.
[{"type":"attachment","content":[208,207,17,224,161,177,26,225,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,0,3,0,254,255,9,0,6,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,54,0,0,0,0,0,0,0,0,16,0,0,254,255,255,255,0,0,0,0,254,255,255,255,0,0,0,0,53,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,9,8,16,0,0,6,5,0,84,56,205,7,193,0,2,0,6,8,0,0,225,0,2,0,176,4,193,0,2,0,0,0,226,0,0,0,92,0,112,0,19,0,0,65,110,97,32,67,114,105,115,116,105,110,97,32,77,111,114,101,110,111,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,66,0,2,0,176,4,97,1,2,0,0,0,192,1,0,0,61,1,2,0,1,0,156,0,2,0,17,0,25,0,2,0,0,0,18,0,2,0,0,0,19,0,2,0,0,0,175,1,2,0,0,0,188,1,2,0,0,0,61,0,18,0,0,0,0,0,66,84,149,31,56,0,0,0,0,0,1,0,88,2,64,0,2,0,0,0,141,0,2,0,0,0,34,0,2,0,0,0,14,0,2,0,1,0,183,1,2,0,0,0,218,0,2,0,0,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,0,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,0,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,0,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,0,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,30,0,220,0,0,0,8,0,144,1,0,0,0,2,0,0,7,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,49,0,42,0,104,1,0,0,54,0,144,1,0,0,0,2,0,0,13,1,67,0,97,0,108,0,105,0,98,0,114,0,105,0,32,0,76,0,105,0,103,0,104,0,116,0,49,0,30,0],"contentType":"application/vnd.ms-excel","partId":"2","release":null,"contentDisposition":"attachment","filename":"6 PĂłs-Pago Teste EFATURA ICCID 4008404_4008409.xls","headers":{"content-type":{"value":"application/vnd.ms-excel","params":{"name":"6 PĂłs-Pago Teste EFATURA ICCID 4008404_4008409.xls"}},"content-description":"=?iso-8859-1?Q?6_P=F3s-Pago_Teste_EFATURA_ICCID_4008404=5F4008409.xls?=","content-disposition":{"value":"attachment","params":{"filename":"6 PĂłs-Pago Teste EFATURA ICCID 4008404_4008409.xls","size":"28672","creation-date":"Tue, 13 Dec 2022 13:04:10 GMT","modification-date":"Tue, 13 Dec 2022 13:00:33 GMT"}},"content-transfer-encoding":"base64"},"checksum":"0e9e7cece72f119073619538424316a8","size":28672}]
I have tried to download the file using the following code snippet in the function node to extract and save the attachments:
var attachments = msg.payload.attachments;
for (var i = 0; i < attachments.length; i++) {
var attachment = attachments[i];
// Save the attachment to disk
node.fs.writeFile("C:\\{Users}\\Username\\Documents\\attachments" + i, attachment.content, 'base64', function(err) {
if (err) {
node.error("Failed to save attachment: " + err);
} else {
node.log("Attachment saved successfully.");
}
});
}
But didn't work... is there other way to do this?