fix(firstleg): allow customs uploads up to 50MB
This commit is contained in:
@@ -4,6 +4,10 @@ spring:
|
|||||||
username: ${FIRSTLEG_DB_USERNAME}
|
username: ${FIRSTLEG_DB_USERNAME}
|
||||||
password: ${FIRSTLEG_DB_PASSWORD}
|
password: ${FIRSTLEG_DB_PASSWORD}
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: ${FIRSTLEG_MULTIPART_MAX_FILE_SIZE:50MB}
|
||||||
|
max-request-size: ${FIRSTLEG_MULTIPART_MAX_REQUEST_SIZE:52MB}
|
||||||
baiyue.clients.warehouse.url: ${WAREHOUSE_SERVICE_URL:}
|
baiyue.clients.warehouse.url: ${WAREHOUSE_SERVICE_URL:}
|
||||||
baiyue.clients.order.url: ${ORDER_SERVICE_URL:}
|
baiyue.clients.order.url: ${ORDER_SERVICE_URL:}
|
||||||
baiyue.clients.file.url: ${FILE_SERVICE_URL:}
|
baiyue.clients.file.url: ${FILE_SERVICE_URL:}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ spring.datasource:
|
|||||||
url: ${FIRSTLEG_DB_URL:jdbc:mysql://127.0.0.1:3306/baiyue_firstleg?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true}
|
url: ${FIRSTLEG_DB_URL:jdbc:mysql://127.0.0.1:3306/baiyue_firstleg?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true}
|
||||||
username: ${FIRSTLEG_DB_USERNAME:root}
|
username: ${FIRSTLEG_DB_USERNAME:root}
|
||||||
password: ${FIRSTLEG_DB_PASSWORD:123456}
|
password: ${FIRSTLEG_DB_PASSWORD:123456}
|
||||||
|
spring.servlet.multipart.max-file-size: ${FIRSTLEG_MULTIPART_MAX_FILE_SIZE:50MB}
|
||||||
|
spring.servlet.multipart.max-request-size: ${FIRSTLEG_MULTIPART_MAX_REQUEST_SIZE:52MB}
|
||||||
baiyue.clients.warehouse.url: ${WAREHOUSE_SERVICE_URL:}
|
baiyue.clients.warehouse.url: ${WAREHOUSE_SERVICE_URL:}
|
||||||
baiyue.clients.order.url: ${ORDER_SERVICE_URL:}
|
baiyue.clients.order.url: ${ORDER_SERVICE_URL:}
|
||||||
baiyue.clients.file.url: ${FILE_SERVICE_URL:}
|
baiyue.clients.file.url: ${FILE_SERVICE_URL:}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ spring:
|
|||||||
config.namespace: ${NACOS_NAMESPACE:public}
|
config.namespace: ${NACOS_NAMESPACE:public}
|
||||||
servlet:
|
servlet:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 5MB
|
max-file-size: ${FIRSTLEG_MULTIPART_MAX_FILE_SIZE:50MB}
|
||||||
max-request-size: 6MB
|
max-request-size: ${FIRSTLEG_MULTIPART_MAX_REQUEST_SIZE:52MB}
|
||||||
baiyue:
|
baiyue:
|
||||||
carrier-schedule:
|
carrier-schedule:
|
||||||
providers:
|
providers:
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ components:
|
|||||||
InboundIds: {name: inboundIds, in: query, required: true, schema: {type: array, minItems: 1, maxItems: 200, items: {$ref: '#/components/schemas/LongId'}}}
|
InboundIds: {name: inboundIds, in: query, required: true, schema: {type: array, minItems: 1, maxItems: 200, items: {$ref: '#/components/schemas/LongId'}}}
|
||||||
requestBodies:
|
requestBodies:
|
||||||
ActionBody: {required: true, content: {application/json: {schema: {$ref: '#/components/schemas/ActionRequest'}}}}
|
ActionBody: {required: true, content: {application/json: {schema: {$ref: '#/components/schemas/ActionRequest'}}}}
|
||||||
FileBody: {required: true, content: {multipart/form-data: {schema: {type: object, required: [file], properties: {file: {type: string, format: binary, description: 任意格式且最大50MB}}}}}}
|
FileBody: {required: true, content: {multipart/form-data: {schema: {type: object, required: [file], properties: {file: {type: string, format: binary, description: 任意格式且最大50MB;multipart整请求上限52MB}}}}}}
|
||||||
responses:
|
responses:
|
||||||
ContainerResponse: {description: 成功或业务失败, content: {application/json: {schema: {$ref: '#/components/schemas/ContainerEnvelope'}}}}
|
ContainerResponse: {description: 成功或业务失败, content: {application/json: {schema: {$ref: '#/components/schemas/ContainerEnvelope'}}}}
|
||||||
DocumentResponse: {description: 成功或业务失败, content: {application/json: {schema: {$ref: '#/components/schemas/DocumentEnvelope'}}}}
|
DocumentResponse: {description: 成功或业务失败, content: {application/json: {schema: {$ref: '#/components/schemas/DocumentEnvelope'}}}}
|
||||||
|
|||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package com.baiyue.firstleg.customs.container;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class ContainerCustomsMultipartConfigurationContractTest {
|
||||||
|
private static final String FILE_LIMIT = "${FIRSTLEG_MULTIPART_MAX_FILE_SIZE:50MB}";
|
||||||
|
private static final String REQUEST_LIMIT = "${FIRSTLEG_MULTIPART_MAX_REQUEST_SIZE:52MB}";
|
||||||
|
|
||||||
|
@Test void applicationAndEnvironmentConfigsPermitFiftyMegabyteCustomsFiles() throws Exception {
|
||||||
|
assertLimits(read("firstleg/src/main/resources/application.yml"));
|
||||||
|
assertLimits(read("config/nacos/cn/firstleg-service.yml"));
|
||||||
|
assertLimits(read("config/nacos/local/firstleg-service.yml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test void customsOpenApiPublishesFileAndMultipartRequestLimits() throws Exception {
|
||||||
|
assertThat(read("firstleg/src/main/resources/openapi/customs-v1.yaml"))
|
||||||
|
.contains("任意格式且最大50MB", "multipart整请求上限52MB");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void assertLimits(String yaml) {
|
||||||
|
assertThat(yaml).contains("max-file-size: " + FILE_LIMIT, "max-request-size: " + REQUEST_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String read(String repositoryPath) throws Exception {
|
||||||
|
Path direct = Path.of(repositoryPath);
|
||||||
|
Path path = Files.exists(direct) ? direct : Path.of("..").resolve(repositoryPath).normalize();
|
||||||
|
return Files.readString(path, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user