Hi,
Firstly apologies for the cross-post but I'm really stuck with this now... I'm trying to upload a file from an iOS device via Xamarin and the HttpClient.PostAsync method.
The post arrives at the MSMVC controller and the request length looks correct but the file count is 0. I've tested the same controller with an upload from a browser and it all works well. I just can't get this to work. Am I missing a header? is the MediaHeaderType correct? Am I missing something iOS Specific?
public async Task UploadPhotoAsync(byte[] photoBytes)
{
try
{
var content = new MultipartFormDataContent();
var fileContent = new ByteArrayContent(photoBytes);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "image.jpg",
Name = "file"
};
content.Add(fileContent);
await _httpClient.PostAsync(ApiConfiguration.UploadUri, content);
}
catch(Exception ex)
{
_logger.LogError(ex.Message);
throw;
}
}