How process POST with multipart/form-data without Content-Disposition header in Spring Boot

Viewed 1219

I am using Sprin Boot and i need to process this type of request:

POST /post HTTP/1.0
content-type: multipart/form-data;boundary=482CFA229C8C00EBE48F4FAE633EDB4A0
content-length: 157
x-numbercomps: 1 
user-agent: SAP NetWeaver Application Server (1.0;750)
host: 172.0.0.1:8080
accept-encoding: gzip

--482CFA229C8C00EBE48F4FAE633EDB4A0
Content-Type: text/plain
Content-Length: 11
X-compId: test.txt

content
--482CFA229C8C00EBE48F4FAE633EDB4A0--

Controller:

@PostMapping(value = "/**", params = {"create"}, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String createPost(HttpServletRequest request,
                         @RequestParam MultipartFile... files) {
    //do some staff

    return "";
}

In the controller there is no error, but the number of MuiltipartFiles is 0

Without Content-Disposition Spring can not recognize MultipartFile.

Anyone have any ideas how to handle it?

Thanks.

1 Answers

I have used your controller and posted multiple files and seems no issue and checked all headers and there was no Content-Disposition in my header but I can see all files details.Seems issue is sending request not Spring boot side.

Please see below screenshots:

Multipart file request

and here is header I received and there is no Content-Disposition

Headers

Related