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?