疯狂的狮子li
2020-06-18 eb7c29c647df5f3aa335f5075e78fdf7c675079d
解决文件上传bug,因undertow与tomcat对文件写入的底层实现不同,无需创建新文件
已修改1个文件
16 ■■■■ 文件已修改
ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
@@ -2,8 +2,6 @@
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;
@@ -17,7 +15,7 @@
/**
 * 文件上传工具类
 *
 *
 * @author ruoyi
 */
public class FileUploadUtils
@@ -84,6 +82,7 @@
        }
        catch (Exception e)
        {
            e.printStackTrace();
            throw new IOException(e.getMessage(), e);
        }
    }
@@ -139,10 +138,11 @@
        {
            desc.getParentFile().mkdirs();
        }
        if (!desc.exists())
        {
            desc.createNewFile();
        }
        // 解决undertow文件上传bug,因底层实现不同,无需创建新文件
//        if (!desc.exists())
//        {
//            desc.createNewFile();
//        }
        return desc;
    }
@@ -229,7 +229,7 @@
    /**
     * 获取文件名的后缀
     *
     *
     * @param file 表单文件
     * @return 后缀名
     */