From 64e146dfee7e06da675c9467e4e059301cec08d1 Mon Sep 17 00:00:00 2001 From: yoyuzh Date: Thu, 19 Mar 2026 10:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=8F=AF=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=89=A9=E5=A4=A7=E8=87=B3500MB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yoyuzh/config/FileStorageProperties.java | 2 +- backend/src/main/resources/application.yml | 6 +++--- .../java/com/yoyuzh/files/FileServiceTest.java | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/com/yoyuzh/config/FileStorageProperties.java b/backend/src/main/java/com/yoyuzh/config/FileStorageProperties.java index 9953079..2eaa061 100644 --- a/backend/src/main/java/com/yoyuzh/config/FileStorageProperties.java +++ b/backend/src/main/java/com/yoyuzh/config/FileStorageProperties.java @@ -8,7 +8,7 @@ public class FileStorageProperties { private String provider = "local"; private final Local local = new Local(); private final Oss oss = new Oss(); - private long maxFileSize = 50 * 1024 * 1024L; + private long maxFileSize = 500L * 1024 * 1024L; public String getProvider() { return provider; diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index e0907dc..a9f02d1 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -18,8 +18,8 @@ spring: format_sql: true servlet: multipart: - max-file-size: 50MB - max-request-size: 50MB + max-file-size: 500MB + max-request-size: 500MB app: jwt: @@ -27,7 +27,7 @@ app: expiration-seconds: 86400 storage: root-dir: ./storage - max-file-size: 52428800 + max-file-size: 524288000 cqu: base-url: https://example-cqu-api.local require-login: true diff --git a/backend/src/test/java/com/yoyuzh/files/FileServiceTest.java b/backend/src/test/java/com/yoyuzh/files/FileServiceTest.java index 0c2ab24..b65c1ef 100644 --- a/backend/src/test/java/com/yoyuzh/files/FileServiceTest.java +++ b/backend/src/test/java/com/yoyuzh/files/FileServiceTest.java @@ -42,7 +42,7 @@ class FileServiceTest { @BeforeEach void setUp() { FileStorageProperties properties = new FileStorageProperties(); - properties.setMaxFileSize(50 * 1024 * 1024); + properties.setMaxFileSize(500L * 1024 * 1024); fileService = new FileService(storedFileRepository, fileContentStorage, properties); } @@ -80,6 +80,21 @@ class FileServiceTest { verify(fileContentStorage).prepareUpload(7L, "/docs", "notes.txt", "text/plain", 12L); } + @Test + void shouldAllowInitiatingUploadAtFiveHundredMegabytes() { + User user = createUser(7L); + long uploadSize = 500L * 1024 * 1024; + when(storedFileRepository.existsByUserIdAndPathAndFilename(7L, "/docs", "movie.zip")).thenReturn(false); + when(fileContentStorage.prepareUpload(7L, "/docs", "movie.zip", "application/zip", uploadSize)) + .thenReturn(new PreparedUpload(true, "https://upload.example.com", "PUT", Map.of(), "movie.zip")); + + InitiateUploadResponse response = fileService.initiateUpload(user, + new InitiateUploadRequest("/docs", "movie.zip", "application/zip", uploadSize)); + + assertThat(response.direct()).isTrue(); + verify(fileContentStorage).prepareUpload(7L, "/docs", "movie.zip", "application/zip", uploadSize); + } + @Test void shouldCompleteDirectUploadAndPersistMetadata() { User user = createUser(7L);