| | |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | | public static final String uploadImg(String baseDir, MultipartFile file) throws IOException |
| | | { |
| | | try |
| | | { |
| | | int fileNameLength = Objects.requireNonNull(file.getOriginalFilename()).length(); |
| | | if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) |
| | | { |
| | | throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); |
| | | } |
| | | |
| | | assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); |
| | | String fileName = StringUtils.format("{}.{}", FilenameUtils.getBaseName(file.getOriginalFilename()), getExtension(file)); |
| | | |
| | | |
| | | String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); |
| | | System.out.println(absPath+"[[[[[[[[[[[[[[[[["); |
| | | file.transferTo(Paths.get(absPath)); |
| | | return getPathFileName(baseDir, fileName); |
| | | |
| | | |
| | | // return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, true); |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | | /** |
| | | * 文件上传 |
| | | * |