You could do something like this on the client side:
HttpClient client = new HttpClient();
var imageStream = File.OpenRead(@"C:\p1.jpg");
var content = new StreamContent(imageStream);
content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
var response = await client.PostAsync("URL", content);
You can get HttpClient from the NugetPackage Microsoft.Net.Http
On the REST API side (receiving end), you can then take it from the Request.Content object, something like this:
public void Post()
{
using (var fileStream = File.Create("C:\\NewFile.jpg"))
{
using (MemoryStream tempStream = new MemoryStream())
{
var task = this.Request.Content.CopyToAsync(tempStream);
task.Wait();
tempStream.Seek(0, SeekOrigin.Begin);
tempStream.CopyTo(fileStream);
tempStream.Close();
}
}
}