/** * Copyright 2019 DH * All right reserved. * 项目名称: 大恒泰山系统 * 创建日期:2023/10/8 */ package org.springblade.config; import cn.hutool.core.io.FileUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.servlet.MultipartConfigElement; /*** * Date:2023/10/8 * Title:文件所属模块(必须填写) * Description:对本文件的详细描述,原则上不能少于30字 * @author dylan * @version 1.0 * Remark:认为有必要的其他信息 */ @Configuration public class MultipartConfig { @Value("${spring.servlet.multipart.location}") private String tmpLocation; @Bean public MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); System.out.println("******************************* MultipartConfigElement"); // 若没有该目录,则创建,此处使用了第三方插件的FileUtil,各位可以使用原生File实现该逻辑 if (!FileUtil.exist(tmpLocation)) { FileUtil.mkdir(tmpLocation); } factory.setLocation(tmpLocation); return factory.createMultipartConfig(); } }