美文网首页
The temporary upload location xx

The temporary upload location xx

作者: 超级笔记本 | 来源:发表于2020-04-26 11:03 被阅读0次

需要配置上传文件的缓存路径,并创建对应目录,三种方式
1、yml文件配置

spring:
    multipart:
      # 单个文件的最大值
      max-file-size: 100MB
      # 最大支持请求大小
      max-request-size: 100MB
      location: C:\logs\temp\

2、启动文件添加

 @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        String location = System.getProperty("user.dir") + "/data/tmp";
        File tmpFile = new File(location);
        if (!tmpFile.exists()) {
            tmpFile.mkdirs();
        }
        factory.setLocation(location);
        return factory.createMultipartConfig();
    }

3、新建配置文件

@Configuration
public class MultipartConfig {

    /**
     * 文件上传临时路径
     */
    @Bean
    MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        String location = System.getProperty("user.dir") + "/data/tmp";
        File tmpFile = new File(location);
        if (!tmpFile.exists()) {
            tmpFile.mkdirs();
        }
        factory.setLocation(location);
        return factory.createMultipartConfig();
    }
}

参考文章:https://www.jianshu.com/p/6cbe87a8ba99

相关文章

网友评论

      本文标题:The temporary upload location xx

      本文链接:https://www.haomeiwen.com/subject/zyldwhtx.html