How to check if file size is greater than

Describe the problem/error/question

How do I check if a file size is greater than 10MB? cause files are not in the same measurement they can be kb or mb, gb

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.1.5
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Ubuntu 24.04 LTS

@Ruriko You cannot just directly read file size from that binary file but what i have is something what you can do and it works for me:

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, hope this helps.

1 Like

Hi @Ruriko,

As friends have mentioned, I’d like to add the most straightforward method for future reference and indexing,

Since the binary object now already has a property called bytes, you just need to convert it to the unit you want,

For example, to convert it to MB, you can use this expression:

{{ $binary.data.bytes/1024/1024 }}

1 Like