zoukankan      html  css  js  c++  java
  • POST a string and an image in one request using HttpClient

    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);
    }
    

      

  • 相关阅读:
    3.17JSP作业
    JSP第二次作业
    JSP第一次作业
    软件测试课堂练习
    增删改查
    登录界面
    购物商城
    图床
    JSP-2020年4月14日-第七周
    JSP-2020年4月12日-第六周
  • 原文地址:https://www.cnblogs.com/wlqsmiling/p/4368827.html
Copyright © 2011-2022 走看看