Closed elegos closed 1 year ago
It looks like you're trying to create a SampleResource
from json. To do so, you don't need @ModelAttribute
on the controller method's parameter. You also need to send a request that indicates that the part is json. Assuming you've created a file named meta.json
with the require contents, one way to do so with curl is the following:
$ curl -X POST http://localhost:8888/demo/ -F 'meta=@meta.json;type=application/json' -Fmy_file=@my_file.ext
If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
Dear Spring boot team,
recently I had the need to create POST requests with content type multipart/form-data. In particular I have the need to load a file and the relative metadata.
I've created a very simple project to demonstrate this, which you can find attached. I propose the controller right here:
And this is SampleResource:
The call is being made with curl, as follows:
Here is the project that you can build and run reproducing the problem: multipart_bug.tar.gz
The sample project is using SpringBoot 2.7.11, though my target application is running SpringBoot 2.5.4 (being part of an older application).
The expected result should be that metadata should be filled with
{foo: "string", bar: 0}
Thank you