Browse Source

U-文件上传修改

liyang1 6 months ago
parent
commit
f32b9b6124

+ 5 - 1
src/main/java/com/ywt/gateway/filter/RequestParamGlobalFilter.java

@@ -11,6 +11,7 @@ import org.springframework.core.io.buffer.DataBufferUtils;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.codec.CodecConfigurer;
 import org.springframework.http.codec.HttpMessageReader;
+import org.springframework.http.codec.ServerCodecConfigurer;
 import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
 import org.springframework.stereotype.Component;
@@ -30,8 +31,11 @@ import java.util.List;
  */
 @Component
 public class RequestParamGlobalFilter implements GlobalFilter, Ordered {
+
+
+    // codecConfigurer.getReaders(),来获取spring.codec.max-in-memory-size的配置
     @Autowired
-    private CodecConfigurer codecConfigurer;
+    private ServerCodecConfigurer codecConfigurer ;
 
     private static final Logger log = LoggerFactory.getLogger(RequestParamGlobalFilter.class);
 

+ 5 - 2
src/main/resources/application.yml

@@ -11,8 +11,8 @@ spring:
       discovery:
         server-addr: @nacos.address@
         namespace: @nacos.namespace@
-        username: @nacos.username@
-        password: @nacos.password@
+        username:
+        password:
         metadata: # 保证微服务5s内能快速响应上线线
           preserved.heart.beat.interval: 1000 # 该实例在客户端上报心跳的间隔时间,单位为毫秒,默认为5s
           preserved.heart.beat.timeout: 5000 # 该实例在不发送心跳后,从健康到不健康的时间,单位为毫秒,默认为15s
@@ -27,6 +27,9 @@ spring:
       httpclient:
         connect-timeout: 1000
         response-timeout: 55s
+  # 文件上传时报错
+  codec:
+    max-in-memory-size: 10MB
 
 logging:
   level: