REST接口POST方法发送文件到服务器(C#)
来源:互联网 发布:中译俄在线翻译软件 编辑:程序博客网 时间:2024/05/16 15:40
using System;using System.IO;using System.Net;using System.Text;namespace xxxx{ public class WebRequestPostExample { public static void Main() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http###files/Cygwin.pdf"); FileStream fs = new FileStream(@"D:\Cygwin.ISO", FileMode.Open, FileAccess.Read); Byte[] bytes = new Byte[10240]; request.Method = "POST"; request.Proxy = null; request.Headers.Add("XXX", "XXX"); request.ContentType = "application/octet-stream"; Stream dataStream = request.GetRequestStream(); int count = fs.Read(bytes, 0, 10240); while (count != 0) { dataStream.Write(bytes, 0, count); count = fs.Read(bytes, 0, 10240); } fs.Close(); dataStream.Close(); try { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); response.Close(); } catch (System.Exception ex) { Console.WriteLine("!!!!!!ERROR!!!!!!!!" + ex.ToString() + "!!!!!!!!ERROR!!!!!!!!"); } } }}
代码可能有误
- REST接口POST方法发送文件到服务器(C#)
- REST接口GET方法获取文件保存到本地(C#)
- 利用TJSONArray向REST服务器发送文件
- 利用TJSONArray向REST服务器发送文件 .
- 将文件通过http的post方法上传到服务器
- QT 通过POST方法,上传文件到服务器
- Post方式发送UIImage数据到服务器
- Post方式发送UIImage数据到服务器 .
- Post方式发送UIImage数据到服务器
- android,post发送数据到服务器
- HttpURLConnection 发送(POST)数据到服务器
- post怎么不能发送数据到服务器
- 客户端发送POST请求数据到服务器
- http post 文件 到服务器
- (二)glassFish提供的rest接口的post方法
- Java客户端通过Http发送POST请求上传文件到web服务器
- 用idhttp post 方法发送数据到服务器上。实现数据和网页的交互。
- 使用post()方法以POST方式从服务器发送数据
- htmL 学习网站
- C# 冒泡排序
- 谁是HTML5新规则下的牺牲品?
- xfire中对集合的配置
- Excel技巧--F5
- REST接口POST方法发送文件到服务器(C#)
- 京东商城暂停所有地铁自提点:或因租金成本高
- SQL Server 2008连接字符串写法大全
- Convert、Parse、TryParse、(int)等区别
- .Net+EF连接Oracle 10、11 开发,ODAC安装配置与使用详解
- UML简介
- Linux下Bluetooth编程
- vs2005编译Openssl
- ABAP 字符串截取