Spring Cloud Netflix Zuul large file upload

谁说我不能喝 提交于 2020-01-03 06:44:05

问题


I'm using Spring Boot for a project and i'm trying to upload large files but somehow it doesnt work.

I have Spring Boot + Zuul (@EnableZuulProxy) running on port 8080 and then another microservice (Lets call it datastore) that should handle the upload.

I post a multipart request to http://localhost:8080/zuul/my/upload/endpoint which contains a file and a text string.

When I upload a file of 100MB everything works fine. Zuul passes the request to the datastore and the request comes in and is stored. But when I try to upload a larger file (150MB) Zuul processes the request and passes it to the datastore but then somewhere one of the multipart parameters is stripped from the request and then the datastore error returns a 400 and says 'Required request part 'string' is not present'.

I have the following configuration in both microservice (zuul and datastore)

spring:
  servlet:
    multipart:
      max-file-size: 1000MB
      max-request-size: 1000MB

Does anyone have any idea how to solve this? I've tried adding the CommonsMultipartResolver but that didn't change anything.


回答1:


Instead of servlet, you should use http.

In my Zuul application.yml following properties work:

spring:
  http:  
    multipart:
      max-file-size: 1000MB
      max-request-size: 1000MB

In Spring boot 2 following properties work:

spring:
  servlet:
    multipart:
      max-file-size: 1000MB
      max-request-size: 1000MB

Here the properties are explained:

{
   "name": "spring.http.multipart.max-file-size",
   "type": "java.lang.String",
   "description": "Max file size. Values can use the suffixes \"MB\" or \"KB\" to indicate megabytes or\n kilobytes respectively.",
   "sourceType": 
   "org.springframework.boot.autoconfigure.web.MultipartProperties",
   "defaultValue": "1MB"
},
{
   "name": "spring.http.multipart.max-request-size",
   "type": "java.lang.String",
   "description": "Max request size. Values can use the suffixes \"MB\" or \"KB\" to indicate megabytes or\n kilobytes respectively.",
   "sourceType": 
   "org.springframework.boot.autoconfigure.web.MultipartProperties",
   "defaultValue": "10MB"
},


来源:https://stackoverflow.com/questions/49317279/spring-cloud-netflix-zuul-large-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!