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

API Explorer: IFormCollection is considered as KeyValuePairOfStringAndStringValues #1633

Open
ranouf opened this issue Sep 26, 2018 · 1 comment

Comments

@ranouf
Copy link

ranouf commented Sep 26, 2018

Hi,

I would like to upload multiple file as I wrote here (#1421 (comment)), from what I read on internet (aspnet/Mvc#7719), IEnumerable doesnt work when you want to upload multiple files, to make it work, you need to use IFormCollection.

This is my DTO:

public class SampleDetailsDto
{
    public Guid Id{ get; set; }
    public string Text { get; set; }
    public IFormCollection Images { get; set; }
}

Controller:

[HttpPut]
[Route("{id:guid}")]
public async Task<IActionResult> UpdateAsync([FromRoute]Guid id, [FromForm] SampleDetailsDtodto)
{
    Console.WriteLine(dto.Text); 
    Console.WriteLine(dto.Images.Length);
    return OK();
}

Class generated by NSWAG:

export class SampleDto implements ISampleDto {
    text?: string | undefined;
    image?: KeyValuePairOfStringAndStringValues[] | undefined;
    id?: string | undefined;
}

Maybe there is a reason I ignore? But I think the best way to "translate" it from C# to Typescript could be FileList or File[], what do you think?

@RicoSuter RicoSuter changed the title IFormCollection is considered as KeyValuePairOfStringAndStringValues API Explorer: IFormCollection is considered as KeyValuePairOfStringAndStringValues Oct 3, 2018
@RicoSuter
Copy link
Owner

Is this also caused by this ASP.NET Core "bug"?

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

No branches or pull requests

2 participants