首页 > Web开发 > 详细

POST a string and an image in one request using HttpClient

时间:2015-03-26 17:27:41      阅读:293      评论:0      收藏:0      [点我收藏+]
using Windows.Web.Http;
using Windows.Web.Http.Headers;

private async void Foo()
{
    // the image
    var fileStream = await file.OpenReadAsync();
    var streamContent = new HttpStreamContent(fileStream);
    var filename = "myImage.png";

    // the text
    var text = "oompa loompas";
    var stringContent = new HttpStringContent(text);

    // Putting all together.
    var formDataContent = new HttpMultipartFormDataContent();
    formDataContent.Add(streamContent, "myImage", fileName);
    formDataContent.Add(stringContent, "myString");

    // Send it to the server.
    var response = await (new HttpClient()).PostAsync(uri, formDataContent);
}

  

POST a string and an image in one request using HttpClient

原文:http://www.cnblogs.com/wlqsmiling/p/4368827.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!