I don’t have an answer for everything you are looking for, but I wrote bonk[1] to solve a similar issue, as I needed to ensure users weren’t uploading porn[2]. Maybe you can find an use for it too.
[1]: https://git.sr.ht/~jamesponddotco/bonk
[2]: Because I host in Germany.