[c#][Windows 10 | Windows 10 mobile | Windows Phone] HttpClient 实现form-data POST上传请求
来源:互联网 发布:国外播放器软件 编辑:程序博客网 时间:2024/05/23 02:05
HttpClient _httpClient = new HttpClient();CancellationTokenSource _cts = new CancellationTokenSource();
构建传输的文本:
HttpStringContent uidStringContent = new HttpStringContent(“string文本”);
构建传输的文件:
IStorageFile saveFile = await applicationFolder.CreateFileAsync("head.png", CreationCollisionOption.OpenIfExists);IRandomAccessStreamWithContentType stream1 = await saveFile.OpenReadAsync();HttpStreamContent streamContent = new HttpStreamContent(stream1);
构建HTTP内容:
HttpMultipartFormDataContent fileContent = new HttpMultipartFormDataContent();fileContent.Add(streamContent, "photo", "head.png");fileContent.Add(uidStringContent, "uid");
发送HTTP请求:
HttpResponseMessage response = await _httpClient.PostAsync(new Uri("your Uri"), fileContent).AsTask(_cts.Token);string head = Utils.ConvertUnicodeStringToChinese(await response.Content.ReadAsStringAsync().AsTask(_cts.Token));
1 0
- [c#][Windows 10 | Windows 10 mobile | Windows Phone] HttpClient 实现form-data POST上传请求
- Windows Mobile Phone全屏开发
- Windows Mobile Form Automatic Scrollbar
- 实现一键删除 windows mobile phone 通话记录
- Windows (wince、 windows mobile、windows phone)错误代码大全
- Windows (wince、 windows mobile、windows phone)错误代码大全
- Windows (wince、 windows mobile、windows phone)错误代码大全
- Windows (wince、 windows mobile、windows phone)错误代码大全
- Windows (wince、 windows mobile、windows phone)错误代码大全
- windows mobile GPS NMEA data
- Windows Mobile 天气预报实现
- Windows Phone HttpClient解析gb2312网页
- Mircosoft 正式把Windows Mobile改名为Windows Phone
- Windows Mobile 的历程(Windows Phone的前身)
- Microsoft Procket PC& Windows Mobile&Windows Phone管中窥豹
- Windows 10 Mobile 安装 apk
- WPF和Windows Phone Post组装函数
- windows phone
- [android] cannot be cast to android.widget.HeaderViewListAdapter
- Android图片高斯模糊的一些方法
- TCP/IP、Http、Socket的区别
- Java NIO系列教程(九) Java NIO与BIO
- 分治法求解集合的众数及其重数
- [c#][Windows 10 | Windows 10 mobile | Windows Phone] HttpClient 实现form-data POST上传请求
- OpenJudge_P8201 河中跳房子
- error LNK2038、error LNK1123
- windows 7 远程桌面失败的问题
- Python猜数字游戏
- 20本最好的免费的Python书籍
- Java JSON(org.json)
- 数列特征
- 分页控件及其CSS样式