Procházet zdrojové kódy

调整上传文件大小限制 https://gitee.com/ghi/dbsyncer/issues/I5P4SX

Signed-off-by: AE86 <836391306@qq.com>
AE86 před 2 roky
rodič
revize
2b868b6e47

+ 0 - 16
dbsyncer-web/src/main/java/org/dbsyncer/web/config/OpenApiConfig.java

@@ -2,14 +2,10 @@ package org.dbsyncer.web.config;
 
 import org.dbsyncer.web.remote.UserService;
 import org.dbsyncer.web.remote.UserServiceImpl;
-import org.springframework.boot.web.servlet.MultipartConfigFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
 import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
-import org.springframework.util.unit.DataSize;
-
-import javax.servlet.MultipartConfigElement;
 
 /**
  * @author AE86
@@ -44,16 +40,4 @@ public class OpenApiConfig {
         return proxy;
     }
 
-    @Bean
-    public MultipartConfigElement multipartConfigElement() {
-        MultipartConfigFactory factory = new MultipartConfigFactory();
-        //上传的单个文件最大值   KB,MB 这里设置为10MB
-        DataSize maxSize = DataSize.ofMegabytes(10);
-        DataSize requestMaxSize = DataSize.ofMegabytes(30);
-        factory.setMaxFileSize(maxSize);
-        /// 设置一次上传文件的总大小
-        factory.setMaxRequestSize(requestMaxSize);
-        return factory.createMultipartConfig();
-    }
-
 }

+ 15 - 0
dbsyncer-web/src/main/java/org/dbsyncer/web/config/WebAppConfig.java

@@ -9,6 +9,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.servlet.MultipartConfigFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.authentication.AuthenticationProvider;
@@ -23,7 +24,9 @@ import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.web.authentication.AuthenticationFailureHandler;
 import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
 import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
+import org.springframework.util.unit.DataSize;
 
+import javax.servlet.MultipartConfigElement;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSessionEvent;
@@ -164,6 +167,18 @@ public class WebAppConfig extends WebSecurityConfigurerAdapter implements Authen
         logger.debug("销毁会话:{}", se.getSession().getId());
     }
 
+    @Bean
+    public MultipartConfigElement multipartConfigElement() {
+        MultipartConfigFactory factory = new MultipartConfigFactory();
+        // 上传单个文件最大值MB
+        DataSize maxSize = DataSize.ofMegabytes(128);
+        DataSize requestMaxSize = DataSize.ofMegabytes(128);
+        factory.setMaxFileSize(maxSize);
+        // 设置一次上传文件的总大小
+        factory.setMaxRequestSize(requestMaxSize);
+        return factory.createMultipartConfig();
+    }
+
     /**
      * 响应
      *