You can't. While send_file streams the file using Flask when using the dev server, it may (and really should for performance) use the web server (nginx, apache, etc.) and X-SendFile in production. Since the web server is beyond the control of the application, you're out of luck.