package com.whut.pan.config; import static com.whut.pan.util.SystemUtil.isWindows; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.io.File; import javax.servlet.MultipartConfigElement; /** * 链接:https://blog.csdn.net/llibin1024530411/article/details/79474953 * 注意:springboot项目,部署到服务器后,运行一段时间后,处理一些文件上传接口时后报异常 * Caused by: java.io.IOException: The temporary upload location [/tmp/tomcat.33230 11741980485887.8080/work/Tomcat/localhost/ROOT] is not valid * at org.apache.catalina.connector.Request.parseParts(Request.java:2844) * Created by zc on 2019/3/6. */ @Configuration public class MultipartConfig { private Logger logger = LoggerFactory.getLogger(this.getClass()); /** * 文件上传临时路径 */ @Bean MultipartConfigElement multipartConfigElement() { MultipartConfigFactory factory = new MultipartConfigFactory(); if (!isWindows()) { String location = System.getProperty("user.dir") + "/data/tmp"; // 目录为:/root/pan/data/tmp logger.warn("临时文件的目录更改于2019-3-6:" + location); File tmpFile = new File(location); if (!tmpFile.exists()) { tmpFile.mkdirs(); } factory.setLocation(location); } return factory.createMultipartConfig(); } }

francochan LV6
2024年5月4日
kkkllll LV2
2024年1月26日
shuangfu LV25
2023年10月19日
molu123456
2023年10月10日
暂无贡献等级
thsgli LV9
2023年3月14日
MAOMAO999999 LV4
2023年3月4日
xxn1234567 LV1
2023年2月1日
cxz2132132 LV11
2022年11月18日
qlpqlp LV7
2022年11月14日
huyuxin LV3
2022年11月9日

yimaoermao LV1
2024年11月28日
Boss绝 LV9
2024年11月12日
charleswang LV7
2024年10月21日
grant1123 LV2
2024年6月22日
TY0165 LV20
2024年6月21日
17380184110
2024年6月19日
暂无贡献等级
来一杯西瓜冰咩 LV6
2024年5月13日
xiaozhi丶 LV15
2024年3月24日
微信网友_6854901408452608
2024年2月6日
暂无贡献等级
wyyz5211314 LV4
2024年1月30日