Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to send image to api using image path

$
0
0

I have this method that gets image from device storage and send it to api

var media = CrossMedia.Current;
var file = await media.PickPhotoAsync();

        // wait until the file is written
        while (File.ReadAllBytes(file.Path).Length == 0)
        {
            System.Threading.Thread.Sleep(1);
        }

        var content = new MultipartFormDataContent();

        content.Add(new StreamContent(file.GetStream()),
            "\"file\"",
            $"\"{file.Path}\"");

        var httpClient = new HttpClient();

        var httpResponseMessage = await httpClient.PostAsync(URL, content);

How to do this using image path without getting image from device storage


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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