Spring 处理文件上传,你是否遇到一下问题?
这里一次解决以上所有问题
Spring文件上传属性配置核心类为 MultipartProperties
package org.springframework.boot.autoconfigure.web.servlet;
@ConfigurationProperties(prefix = "spring.servlet.multipart", ignoreUnknownFields = false)
public class MultipartProperties {/*** Whether to enable support of multipart uploads.*/private boolean enabled = true;/*** Intermediate location of uploaded files.*/private String location;/*** Max file size.*/private DataSize maxFileSize = DataSize.ofMegabytes(1);/*** Max request size.*/private DataSize maxRequestSize = DataSize.ofMegabytes(10);/*** Threshold after which files are written to disk.*/private DataSize fileSizeThreshold = DataSize.ofBytes(0);/*** Whether to resolve the multipart request lazily at the time of file or parameter* access.*/private boolean resolveLazily = false;}
#是否开启上传功能 默认true
spring.abled=true#指定默认上传的文件夹
spring.servlet.multipart.location=#指定默认上传单个文件大小(默认是1MB)
spring.servlet.multipart.max-file-size=5MB#指定所有文件总共大小(默认是10MB)
spring.servlet.multipart.max-request-size=20MB#文件写入磁盘的阈值,默认是0
spring.servlet.multipart.file-size-threshold=5KB#是否延迟解析,默认是false
spring.solve-lazily=false
本文发布于:2024-02-08 19:54:15,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170739342068545.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |