How can i upload multi file.
See original GitHub issueIn my case , i want to upload multi file ,but i get exception java.lang.IllegalStateException: Method has too many Body parameters
,my code like that
@FeignClient(configuration = MultipartFormDataConfig.class)
public class Demo{
@PostMapping(
path = "/upload",
consumes = org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE
)
Response uploadFile(
@RequestPart MultipartFile file1,
@RequestPart MultipartFile file2
);
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Upload multiple files at once - SiteBuilder help - IT Services
Browse to the files you want to upload from your computer and use Ctrl/Cmd +select to choose multiple files. · Select Upload. ·...
Read more >Uploading multiple files - Manual - PHP
Multiple files can be uploaded using different name for input . It is also possible to upload multiple files simultaneously and have the...
Read more >How can I select and upload multiple files with HTML and PHP ...
How can I select and upload multiple files with HTML and PHP, using HTTP POST? ... I have experience doing this with single...
Read more >I need to add multiple files to my online application, but there ...
You can only upload 1 file per field. If you try to upload multiple files in the same field, only 1 (the last...
Read more >Upload Multiple Files at Once | CMS Guide - Brandeis University
Simply follow the instructions on the Uploading and Updating Files page, but instead of selecting or dragging a single file, you can select...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Так, на сколько я вижу вы тут сами уже во всём разобрались…
Ok. I see, that this issue is closed, but I’ll describe here a little workaround. I hope this will help someone. I resolve this in the issue, when I’s trying to send something like this via feign client:
In case of two request parts, when tries create feign client instance Method has too many Body parameters occurs. If I change them to RequestParam, than I get nothing (null).
So I do this in such way, that I create two interface API. The first version, with two RequestPart, is used on side of Controller implementation - in such way it recognizes correctly incoming parts and puts as argues. The second version, used to create feign client, looks like this
I’m using this with feign client configuration
and with fix from PR: https://github.com/OpenFeign/feign-form/pull/97 - it’s needed, if for one field name (here attachments) we’d like send more than one multipart-file.
Then, if we’d like to use upload via feign client, we should call upload and create named multiparts. In this example example:
In this way multi part files names are used as field names. This will be recognized by controller and assigned to dedicated argues.