Esempio n. 1
0
 /**
  * 验证文件大小
  *
  * @param types 文件类型: jpg,gif,png......
  * @throws MessageException
  * @autor yxl 2013-11-04
  */
 public static void type(String types, MultipartFile multipartFile) throws MessageException {
   if (!notNull(multipartFile)) return;
   String fileName = multipartFile.getOriginalFilename().toLowerCase();
   String fileTypeStr = FilePathUtil.getSuffix(fileName).substring(1);
   types = types.toLowerCase();
   if (!types.contains(fileTypeStr)) {
     throw new SimpleMessageException("文件格式错误,只支持:" + types, "file_type_error#" + types);
   }
 }
 /**
  * 获取本地文件绝对路径
  *
  * @return 包括文件名
  */
 public String getFilePath() {
   if (mFilePath == null) {
     setFilePath(FilePathUtil.makeFilePath(mContext, FOLDER_PATH, getFileName()));
   }
   return mFilePath;
 }