I managed to fix the problem by disabling the image optimization feature described in the post here, and now it works.
Since it’s a client side feature, make sure you do a hard refresh in the browser before attempting the upload again - that’s important, otherwise it’ll continue to fail