We've been trying to debug this for the last couple of days. Our users can upload just fine, but files above 10Mb get corrupted whenever they try to download them.
We've been trying several things around filelib.php:2233
if ($filesize > 10000000) { // for large files try to flush and close all buffers to conserve memory while(@ob_get_level()) { if (!@ob_end_flush()) { break; } } }
Even though these parts seem to be the issue for us, I'm convinced there has to be a setting, a parameter missing to our Linux config (RHEL 8 / PHP 7.4.16) that is causing this problem.
See the content of a .docx file below:

We have temporarily bypassed the ob_flush loop and we've been buffering the whole file contents to be able to output uncorrupted files, but for our server's sanity, this isn't the best solution long term. We've been trying to fix our setup on a development instance, without success.
I've tried searching on Google, StackOverflow and on the Moodle forums for a similar issue, without success. Has anyone encountered this issue before ?
If I look at the file directly in the moodledata directory, it is NOT corrupted and can work just fine if I add the correct file extension to it.
This issue happens for pretty much all our documents above 10Mb, and right now unoconv file conversion is not activated, so it should not be the source of the problem. This issue was not happening on our Windows web server.
If anyone has a clue / needs more info, feel free to tell/ask.
Thank you in advance everyone.