2024-02-08

Oof, turns out you can’t trust a browser to tell you the right MIME type for a file upload. I expected some logic involving magic numbers, but it just looks like a mixture of guessing based on file extension, deferring to the OS, and giving up and sending you application/octet-stream.

That said, I do feel a little sorry for browser devs, particularly those that have to support Windows. Found this gem while poking around the Chromium source code:

// This is a primary mapping (overrides the platform) rather than secondary
// to work around an issue when Excel is installed on Windows. Excel
// registers csv as application/vnd.ms-excel instead of text/csv from RFC
// 4180. See https://crbug.com/139105.
{"text/csv", "csv"},

Yeah, of course Excel would do that. 🤦‍♂️