Hey, I’m trying to automate an incoming email. It has attachments, which need to be uploaded to a server (which will be using HTTP with a body request GraphQL). Addiontionally, if it’s possible, I’d like to get the sizes of the attachments and filter them. I’ve been struggling with this all day, is there someone who can help me further?
In n8n you can send such requests using the HTTP Request node, for example:
Perhaps you want to give this approach a go? You would need to adjust the binary property name to match what’s coming from your IMAP trigger node (most likely attachment_0). Let me know if you run into any trouble with this.
Wow, that works great! Thanks so much! Do you have an example code to filter the sizes of the binary, like delete the binary things that are under 900 Bytes? Also if the trigger has multiple binary files, how can I loop over them so they all will be uploaded?
Hi @OpenSourceSimon, sorry it took me a while to check back on this.
There’s two aspects here and I’d actually suggest handling the second part first. Things will generally be simpler once you have converted one item with multiple binary objects into multiple items with one binary object each. This can be achieved with a workflow template I’ve created a while back.
Filtering by size can then be done for each item individually like so. Here’s an example workflow bringing the two pieces together:
At the end you’ll have only items with a certain file size left: