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

MultiFile upload UI does not send files to controller. #1653

Closed
kailasdp2000 opened this issue May 5, 2020 · 1 comment
Closed

MultiFile upload UI does not send files to controller. #1653

kailasdp2000 opened this issue May 5, 2020 · 1 comment

Comments

@kailasdp2000
Copy link

Using Swashbuckle.AspNetCore 4.0.1 installed with nugetpackage manager in a WebAPI solution.
OS - Windows 10
Browser - Chrome - Version 81.0.4044.129 (Official Build) (64-bit)

I intend to implement user friendly interface for multi-file upload.

Issue description -
In solution, IOperationFilter is implemented, it checks:

param.ParameterType == typeof(IFormFile[]) && param.ParameterType.IsArray

If so, then a new parameter is constructed in below fashion:


                var newParameter = new NonBodyParameter
                {
                    Type = "array",
                    In = "formData",
                    Description = oldParameter.Description,
                    Name = oldParameter.Name,
                    Required = oldParameter.Required,
                    CollectionFormat = "multi"
                };

                PartialSchema partialSchema = new PartialSchema { Type = "file", Format = "binary", CollectionFormat = "form-data" };
                newParameter.Items = partialSchema;

                operation.Parameters.Add(newParameter);
                operation.Consumes.Add("multipart/form-data");

Controller signature:

MyController(string branch, [Required] IFormFile[] templateFiles)

With these changes, I get multifile UI and I am able to select multiple files.
But, when the request is received by the controller, templateFiles does not contain any files.

However, when tried from Postman (with Body provided as form-data) it works well.
This seems to be very much similar to the issue mentioned below.
swagger-api/swagger-ui#2617 (comment)

@domaindrivendev
Copy link
Owner

Dup of #1029, which is now resolved

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

No branches or pull requests

2 participants