vendredi 30 septembre 2016

.NET Core + Web API. Get a image from POST

i need help. I sent file to .net core app using postasync method from a desktop app, and i need to obtain this file in .net core app from POST method. Please help to get sended image in web api. Thanks!

 // postasync from desktop app
 public static async void DeloverToServer(StorageFile file)
    {
        var httpClient = new HttpClient();
        var content = new MultipartFormDataContent();

        var randomAccessStream = await file.OpenReadAsync();
        using (var stream = randomAccessStream.AsStreamForRead())
        {
            content.Add(new StreamContent(stream));
            content.Headers.Add("image", "1");

            await httpClient.PostAsync("http://localhost:3160/api/uploadingimage", content);                          
        }
    }


     //this from web api(didnt work)
     [HttpPost]
    public void UploadFile([FromBody]MultipartFormDataContent content)
    {           

    }




Aucun commentaire:

Enregistrer un commentaire