InputStream in = file.getInputStream(); //根据文件头获取文件类型 String type = FileType.getFileType(in); 注意file是MultipartFile类型的。