I don't know, how I can get the file over my .NET Core API and save it as a file.
For example: I upload my test file with the following method:
private void Button_Click(object sender, RoutedEventArgs e) {
var client = new RestSharp.RestClient("https://localhost:44356/api/");
var request = new RestSharp.RestRequest("Upload", RestSharp.Method.POST);
request.AddFile(
"test",
"c:\\kill\\test.wav");
client.Execute(request);
}
And my API receives a request. This method looks like this:
[HttpPost]
public IActionResult UploadFile() {
using(var reader = new StreamReader(Request.Body)) {
var body = reader.ReadToEnd();
}
return View();
}
My body variable contains this:
-------------------------------28947758029299 Content-Disposition: form-data; name="test"; filename="test.wav" Content-Type: application/octet-stream RIFF^b
And now my question:
How can I get the file and save it on my disc?
I use .NET Core 2.1 Webapi & on my Client Restsharp version 106.3.1.