| | |
| | | return Dict.create().set("fileName",fileName).set("suffix",suffix).set("newName",newName); |
| | | } |
| | | |
| | | public static Dict filesUpload(MultipartFile file, String uploadPpath) throws FebsException, IOException { |
| | | if (file.isEmpty()) { |
| | | throw new FebsException("上传的文件不能为空!请重新上传"); |
| | | } |
| | | if (file.getSize() <= 0) { |
| | | throw new FebsException("上传的文件大小需要大于0kb"); |
| | | } |
| | | if (file.getSize() > 200 * 1024* 1024) { |
| | | throw new FebsException("上传的文件大于200M"); |
| | | } |
| | | if (!FileUtil.exist(uploadPpath)) { |
| | | FileUtil.mkdir(uploadPpath); |
| | | } |
| | | //原本名字 |
| | | String fileName = file.getOriginalFilename(); |
| | | String suffix = ""; |
| | | if (fileName.lastIndexOf(".") > 0) { |
| | | //后缀 |
| | | suffix = fileName.substring(fileName.lastIndexOf(".")); |
| | | } |
| | | if(FileUtil.exist(uploadPpath + fileName)){ |
| | | throw new FebsException("文件已经存在"); |
| | | } |
| | | |
| | | //上传 |
| | | file.transferTo(new File(uploadPpath + fileName)); |
| | | return Dict.create().set("fileName",fileName).set("suffix",suffix); |
| | | } |
| | | |
| | | /** |
| | | * 对字节数组字符串进行Base64解码并生成图片 |
| | | */ |