Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Potential Bug in iOS HTTPClient?

$
0
0

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?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>