修改cadai工具,修改后台上传限制
This commit is contained in:
@@ -13,9 +13,9 @@ spring:
|
||||
mode: never
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 50MB
|
||||
# 文件合计最多 200 MiB,额外预留 2 MiB 表单开销。
|
||||
max-request-size: 202MB
|
||||
# 不设独立单文件上限,文件合计最多 500 MiB;额外预留 2 MiB 表单开销。
|
||||
max-file-size: -1
|
||||
max-request-size: 502MB
|
||||
jackson:
|
||||
time-zone: Asia/Shanghai
|
||||
data:
|
||||
@@ -84,8 +84,9 @@ vibemake:
|
||||
step:
|
||||
max-file-bytes: ${STEP_MAX_FILE_BYTES:524288000}
|
||||
urdf:
|
||||
max-file-bytes: ${URDF_MAX_FILE_BYTES:52428800}
|
||||
max-total-bytes: ${URDF_MAX_TOTAL_BYTES:209715200}
|
||||
# 后台与迁移页面统一只限制整批 500 MiB,不沿用社区用户端的单文件配额。
|
||||
max-file-bytes: 0
|
||||
max-total-bytes: 524288000
|
||||
max-files: ${URDF_MAX_FILES:500}
|
||||
ai:
|
||||
enabled: true
|
||||
@@ -108,6 +109,9 @@ vibemake:
|
||||
max-text-bytes: 1048576
|
||||
max-file-bytes: 52428800
|
||||
max-request-bytes: 209715200
|
||||
repository-upload:
|
||||
max-file-bytes: 0
|
||||
max-total-bytes: 524288000
|
||||
file-download:
|
||||
max-bytes: ${FILE_DOWNLOAD_MAX_BYTES:1073741824}
|
||||
timeout: ${FILE_DOWNLOAD_TIMEOUT:5m}
|
||||
|
||||
+53
@@ -118,6 +118,8 @@ class AdminWorkflowTest {
|
||||
@Autowired OssProperties oss;
|
||||
@Autowired OssResourcePaths resourcePaths;
|
||||
@Autowired FakeOssObjectStore ossObjects;
|
||||
@Autowired com.linkerbot.vibemake.service.config.RepositoryUploadProperties uploadLimits;
|
||||
@Autowired com.linkerbot.vibemake.service.config.UrdfProperties urdfLimits;
|
||||
private User admin;
|
||||
private User ordinary;
|
||||
private String token;
|
||||
@@ -190,6 +192,57 @@ class AdminWorkflowTest {
|
||||
.asText();
|
||||
}
|
||||
|
||||
@Test
|
||||
void adminRepositoryUploadAcceptsFilesAboveThePreviewLimitAndCanReplaceAndDeleteThem() throws Exception {
|
||||
assertThat(uploadLimits.getMaxFileBytes()).isZero();
|
||||
assertThat(uploadLimits.getMaxTotalBytes()).isEqualTo(524288000L);
|
||||
String code = createProject();
|
||||
String endpoint = "/admin-api/projects/" + code;
|
||||
String sha = request(signed(get(endpoint + "/tree")), 200).path("data").path("commitSha").asText();
|
||||
MockMultipartFile large = new MockMultipartFile("files", "large.bin", "application/octet-stream",
|
||||
new byte[50 * 1024 * 1024 + 1]);
|
||||
for (int attempt = 0; attempt < 2; attempt++) {
|
||||
sha = request(signed(multipart(endpoint + "/uploads/commit").file(large)
|
||||
.param("expectedCommitSha", sha).param("message", "上传大文件").param("paths", "large.bin")), 200)
|
||||
.path("data").path("commitSha").asText();
|
||||
}
|
||||
request(signed(body(post(endpoint + "/commits"), Map.of("expectedCommitSha", sha, "message", "删除大文件",
|
||||
"changes", List.of(Map.of("action", "DELETE_FILE", "path", "large.bin"))))), 200);
|
||||
assertThat(request(signed(get(endpoint + "/tree")), 200).path("data").path("entries"))
|
||||
.noneMatch(entry -> entry.path("path").asText().equals("large.bin"));
|
||||
|
||||
MockMultipartFile oversized = new MockMultipartFile("files", "oversized.bin", "application/octet-stream", new byte[0]) {
|
||||
@Override public long getSize() { return 524288001L; }
|
||||
};
|
||||
String current = request(signed(get(endpoint + "/tree")), 200).path("data").path("commitSha").asText();
|
||||
assertThat(request(signed(multipart(endpoint + "/uploads/commit").file(oversized)
|
||||
.param("expectedCommitSha", current).param("message", "超限文件")), 413).path("code").asText())
|
||||
.isEqualTo("FILE_TOO_LARGE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectAndImportUrdfShareFiveHundredMiBTotalWithoutAnIndividualFileLimit() throws Exception {
|
||||
assertThat(urdfLimits.getMaxFileBytes()).isZero();
|
||||
assertThat(urdfLimits.getMaxTotalBytes()).isEqualTo(524288000L);
|
||||
oss.setEnabled(true);
|
||||
String endpoint = "/admin-api/projects/" + createProject() + "/urdf";
|
||||
List<Map<String, Object>> files = List.of(Map.of("relativePath", "robot.urdf", "sizeBytes", 524288000L));
|
||||
JsonNode signature = request(signed(body(post(endpoint + "/signature"), Map.of("files", files))), 200).path("data");
|
||||
storeResourceFiles(signature, files);
|
||||
request(signed(body(put(endpoint), Map.of("batchCode", signature.path("batchCode").asText(), "files", files))), 200);
|
||||
request(signed(body(post("/admin-api/project-imports/urdf/signature"), Map.of(
|
||||
"repositoryUrl", "https://github.com/example/robot", "files", files))), 200);
|
||||
List<Map<String, Object>> overflow = List.of(
|
||||
Map.of("relativePath", "robot.urdf", "sizeBytes", 1L),
|
||||
Map.of("relativePath", "meshes/body.stl", "sizeBytes", 524288000L));
|
||||
for (String path : List.of(endpoint + "/signature", "/admin-api/project-imports/urdf/signature")) {
|
||||
assertThat(request(signed(body(post(path), Map.of("repositoryUrl", "https://github.com/example/robot",
|
||||
"files", overflow))), 413).path("code").asText()).isEqualTo("URDF_UPLOAD_TOO_LARGE");
|
||||
}
|
||||
assertThat(request(signed(body(put(endpoint), Map.of("batchCode", signature.path("batchCode").asText(),
|
||||
"files", overflow))), 413).path("code").asText()).isEqualTo("URDF_UPLOAD_TOO_LARGE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fileDownloadsUseStreamingWithCurrentAndHistoricalVersionsAndOwnLimit() throws Exception {
|
||||
String code = createProject();
|
||||
|
||||
Reference in New Issue
Block a user