Try matching uploaded file type before defaulting to first official one

(and memoize `type_from_file_command`)

This solved my issue with mp4 content types (Issue #858)