Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenario with multiple file in array. #97

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Scenario with multiple file in array. #97

wants to merge 4 commits into from

Conversation

rojekabc
Copy link

@rojekabc rojekabc commented Nov 3, 2020

In such situation the field name of multipart is always same, but files in the sending payload are more than one. Using standard HashMap causes, that it's impossible to send more files on same field name. I propose to use here MultiValueMap.

My defined API in spring is:

    @PostMapping(
            path = "/send-documents",
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE
    )
    ResponseResult sendDocuments(
            @RequestPart(name = "documents") MultipartFile[] documents);

When I create feign client with this and put more than one multipart files, I get only one document (last added). MultipartFile contains name (which is used as a field name - here documents) and originalName, which is the original name of the file. If I use another name, than documents, than spring controller doesn't get such element in the table (what's rather expected behavior).

In such situation the field name of multipart is always same, but files in the sending payload are more than one. Using standard HashMap causes, that it's impossible to send more files on same field name. I propose to use here MultiValueMap.
@bomzheg
Copy link

bomzheg commented Jun 30, 2023

Any updates on this pull request? It seems that we still have to manually copy and paste the changes into our projects.

@rojekabc
Copy link
Author

rojekabc commented Jul 2, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants