Upload image to API from IOS greater than 1.5 MB not working

I have an issue when trying to upload an image to an API from my Xamarin Forms IOS app. When I upload a smaller image < 1.25 MB there is no issue, the API sends the file to the destination without any issues. When I select a bigger image > 1.5 MB (I have not tested with images of all sizes just the larger and smaller) the image goes to the API and it is sent to the destination folder and cannot be opened, the error is "We can't open this file.", I know it is not the API, as I have a website that sends very large images to the same API and there are no errors.

var cont = new MultipartFormDataContent(); var image = new StreamContent(img.Image.GetStream()); cont.Add(image, "\"file\"", img.FileName); var uri = App.apiurl + $"FileUpload/" + img.FileName + "/"; using (var client = new HttpClient()) { var response = await client.PostAsync(uri, cont); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return; } }

I have been looking and trying for a couple of days to find a solution but I can't seem to get it to work.

Any help with this would be appreciated.

Sign In or Register to comment.