Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to convert a picture path to mediafile?

$
0
0

I have a picture file path and I am trying to upload this picture to server. When I upload this picture to server I need it's GetStream() value. I will show a sample code, that I have used in another place:

var content = new MultipartFormDataContent();
content.Add(new StreamContent(_mediaFile.GetStream()), "\"file\"", $"\"{_mediaFile.Path}\"");
var response = await httpClient.PostAsync(new Uri("My REST API"), content);

if (response.IsSuccessStatusCode)
{
   //Success
}

Where _mediaFile is a MediaFile

private MediaFile _mediaFile;

But currently, I have only the picture path. So is there any way to convert the picture path to MediaFile or anyway way to get the GetStream() value of the picture path?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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