修复 Debug EML 上传大小限制

This commit is contained in:
andy
2026-07-09 20:16:27 +08:00
parent 666fb41328
commit c190d5e3a8
5 changed files with 52 additions and 0 deletions

View File

@@ -7,6 +7,11 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
flyway:
enabled: true
servlet:
multipart:
# dev Debug EML multipart 上限必须不小于业务文件上限,避免请求进入 Controller 前被 413 拦截。
max-file-size: ${DEBUG_EML_UPLOAD_DEV_MAX_FILE_BYTES:${DEBUG_EML_UPLOAD_MAX_FILE_BYTES:10485760}}
max-request-size: ${DEBUG_EML_UPLOAD_DEV_MAX_REQUEST_BYTES:${DEBUG_EML_UPLOAD_MAX_REQUEST_BYTES:12582912}}
source-message:
original-read:

View File

@@ -7,6 +7,11 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
flyway:
enabled: true
servlet:
multipart:
# prod Debug EML 如被显式开启multipart 上限必须先放行到业务文件上限,再由服务层做受控校验。
max-file-size: ${DEBUG_EML_UPLOAD_PROD_MAX_FILE_BYTES:${DEBUG_EML_UPLOAD_MAX_FILE_BYTES:10485760}}
max-request-size: ${DEBUG_EML_UPLOAD_PROD_MAX_REQUEST_BYTES:${DEBUG_EML_UPLOAD_MAX_REQUEST_BYTES:12582912}}
source-message:
original-read:

View File

@@ -7,6 +7,11 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
flyway:
enabled: true
servlet:
multipart:
# test Debug EML multipart 上限必须不小于业务文件上限,避免请求进入 Controller 前被 413 拦截。
max-file-size: ${DEBUG_EML_UPLOAD_TEST_MAX_FILE_BYTES:${DEBUG_EML_UPLOAD_MAX_FILE_BYTES:10485760}}
max-request-size: ${DEBUG_EML_UPLOAD_TEST_MAX_REQUEST_BYTES:${DEBUG_EML_UPLOAD_MAX_REQUEST_BYTES:12582912}}
source-message:
original-read:

View File

@@ -6,6 +6,11 @@ spring:
default: dev
flyway:
enabled: true
servlet:
multipart:
# Debug EML 默认允许 10MB 文件request 上限略大于文件上限,给 multipart 边界和字段留空间。
max-file-size: ${DEBUG_EML_UPLOAD_MAX_FILE_BYTES:10485760}
max-request-size: ${DEBUG_EML_UPLOAD_MAX_REQUEST_BYTES:12582912}
mybatis-plus:
configuration:

View File

@@ -0,0 +1,32 @@
package cn.nianxx.thhotel.platform.debug.service;
import static org.assertj.core.api.Assertions.assertThat;
import cn.nianxx.thhotel.ThHotelApplication;
import cn.nianxx.thhotel.platform.debug.service.impl.DebugEmlSuperAgentProperties;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@SpringBootTest(
classes = ThHotelApplication.class,
properties = "debug.eml-upload.max-file-bytes=10485760")
@ActiveProfiles("test")
class DebugEmlMultipartConfigurationTest {
@Autowired
private MultipartProperties multipartProperties;
@Autowired
private DebugEmlSuperAgentProperties debugEmlProperties;
@Test
void shouldAllowMultipartRequestBeforeDebugEmlBusinessLimit() {
assertThat(multipartProperties.getMaxFileSize().toBytes())
.isGreaterThanOrEqualTo(debugEmlProperties.getMaxFileBytes());
assertThat(multipartProperties.getMaxRequestSize().toBytes())
.isGreaterThan(debugEmlProperties.getMaxFileBytes());
}
}