Auto-detect filetype based on extension