Binary files - filter by size

Hello,

If been wondering if there’s an easy way to filter binary files based on their size. I’m currently building something like an “archive” for a gmail account, and upload all attachments to Google Drive.

Since there are a lot of low-quality profile pictures or e-mail logos uploaded too, I wanted to ask if it’s possible to filter out every file that is less than a specific size (in my casw 20kb).

Thank you for your time

Hi @one_juru, this isn’t straightforward but should be possible. You can obtain the size of a file by reading the buffer length. Once you have this information available, you could then use an IF node to filer by size like so:

2 Likes

Hey @one_juru,
I adapted a workflow from this forum post Obtaining binary data size to send in upload session with Sharepoint Graph API - #2 by MutedJam to get a file’s size in kilobyte. Is this helping?

Example Workflow

3 Likes

Thank you both for your replys, it’s working pretty well now :slight_smile:

1 Like

I wonder why the new code node does not feed through the binary data, but it works with the old code node (copied from the example above).

If I want to use the new code node, I have to do a merge to be able to access the binary data again.

What is the reason for this?

System: Self-Hosted Version 1.82.1 (SQLite)

Thanks

Hey @Jehu . I am also stumped. I must be missing something… If I use merge to bring the binary data and the buffer length and pass it onto the http post request (In my case passing it on to OpenAI node for transcribing), I am struggling to reference the binary data - any ideas? It also doesn’t work if I remove the if statement. but if I pass the Read/Write Files from Disk directly to the OpenAI node, then it works

I use the “Combine” mode in Merge. Then in the next node you have {{ $json.bufferSize }} and the binary data in ‘data’ field.

1 Like

“Combine” mode did the trick!
“Append” did not work.

Thank you so much @Jehu

1 Like