解决文件上传bug,因undertow与tomcat对文件写入的底层实现不同,无需创建新文件
| | |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | import com.ruoyi.common.core.lang.UUID; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | |
| | | /** |
| | | * 文件上传工具类 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public class FileUploadUtils |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | e.printStackTrace(); |
| | | throw new IOException(e.getMessage(), e); |
| | | } |
| | | } |
| | |
| | | { |
| | | desc.getParentFile().mkdirs(); |
| | | } |
| | | if (!desc.exists()) |
| | | { |
| | | desc.createNewFile(); |
| | | } |
| | | // 解决undertow文件上传bug,因底层实现不同,无需创建新文件 |
| | | // if (!desc.exists()) |
| | | // { |
| | | // desc.createNewFile(); |
| | | // } |
| | | return desc; |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 获取文件名的后缀 |
| | | * |
| | | * |
| | | * @param file 表单文件 |
| | | * @return 后缀名 |
| | | */ |