Convert HttpContent into byte[]
if (!content.IsMimeMultipartContent())
{
throw new UnsupportedMediaTypeException("MIME Multipart Content is not supported");
}
var uploadPath = **whatever**;
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
var provider = new MultipartFormDataStreamProvider(uploadPath);
await content.ReadAsMultipartAsync(provider);
return File.ReadAllBytes(provider.FileData[0].LocalFileName);
HttpContent
has a Async method which return ByteArray i.e (Task of ByteArray)
Byte[] byteArray = await Content.ReadAsByteArrayAsync();
You can run the method synchronously
Byte[] byteArray = Content.ReadAsByteArrayAsync().Result;