you can use the Body.Size property to do so. There are some threads in the Community about that. Example:
You can also search for Body.Size to find different threads.
Thanks Andre, i import rules and config the rule to block >2MB and select request, response, embedded but rules seem didn't work. Can i miss some steps?
thats hard to say - are you able to provide some screenshots of your Rule configuration maybe to allow us to understand how it looks?
Hi Andre, i think this rule check size for entire websites not for one file. when i access a web page that contain link to download files >2MB, the pages block. Maybe need more time to test. Thanks!
One thing to keep in mind, the body.size property is generated by the Web Gateway once the file has been downloaded. So the Web Gateway has to have the entire file before it blocks it (which might defeat the purpose of your rule, which is to save bandwidth I'm guessing).
See attached ruleset which will block based on what the server says the size of the file is (Content-Length):
This does not take into account partial downloads, or chunked data, but will work for most downloads.