I have the following api post method in a controller
[HttpPost("Upload/Csv")]
public async Task<ActionResult<string>> UploadCsv()
i use nSwagStudio to generate the methods for my blazor app which create an interface with the following method
/// <returns>Success</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<string> CsvAsync();
I am trying to use this to upload a csv file to the api side.
Below is how i want to call the CsvAsync Method from the blazor side
using (var ms = file.OpenReadStream(file.Size))
{
var content = new MultipartFormDataContent();
content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
content.Add(new StreamContent(ms, Convert.ToInt32(file.Size)), "csv", file.Name);
await _client.CsvAsync();
}
But i have no way to add the content to the call.
The work around i have in place at the moment is below
using (var ms = file.OpenReadStream(file.Size))
{
var content = new MultipartFormDataContent();
content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
content.Add(new StreamContent(ms, Convert.ToInt32(file.Size)), "csv", file.Name);
var response = await _client.HttpClient.PostAsync(_client.HttpClient.BaseAddress + "Api/File/Upload/Csv", content);
}
How would i go about being able to add the content to the method created by nswagstudio for CsvAsync?