Hi I'm attempting to upload a file to an MSMVC controller using the iOS HTTPClient like so :
public async Task UploadPhotoAsync(string fileName, byte[] photoBytes) { httpClient = new HttpClient(); try { var multipartForm = new MultipartFormDataContent(); var fileContent = new StreamContent(new MemoryStream(photoBytes)); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "file", FileName = "test.jpg", }; fileContent.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); multipartForm.Add(fileContent);
await httpClient.PostAsync("http://192.168.1.80/upload/upload", multipartForm);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
The problem seems to be with the data received at the controller end... The request arrives at the Controller but the Request.Files.Count is zero even though the Request.TotalBytes count is correct?
Has anyone else experienced any issues with HTTPClient on iOS?