转换服务器用.net开发,win7平台
网站采用apache 的 .htpasswd http认证 采用密码保护用户上传的doc等文档源文件。
fp服务器自动从web中依次取得用户上传的doc文档,并且转换后回调web上传接口,实现文档的在线转换
下面的代码是下载web上的源文档用于在线转换
[codesyntax lang=”csharp”]
try { String url = "http://localhost:82/api/T1yAdWXgdGXXb1upjX.jpg"; String fileName = url.Substring(url.LastIndexOf("/") + 1); String refer = url.Substring(0, url.LastIndexOf("/") + 1); System.Net.HttpWebRequest req = System.Net.HttpWebRequest.Create(url) as System.Net.HttpWebRequest; req.AllowAutoRedirect = true; req.Referer = refer; /*发送http认证*/ req.Credentials = new NetworkCredential("xzy", "xzy"); req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13"; System.Net.HttpWebResponse res = req.GetResponse() as System.Net.HttpWebResponse; System.IO.Stream stream = res.GetResponseStream(); byte[] buffer = new byte[32 * 1024]; int bytesProcessed = 0; System.IO.FileStream fs = System.IO.File.Create("tmp/down/" + fileName); int bytesRead; do { bytesRead = stream.Read(buffer, 0, buffer.Length); fs.Write(buffer, 0, bytesRead); bytesProcessed += bytesRead; } while (bytesRead > 0); fs.Flush(); fs.Close(); res.Close(); } catch(Exception err) { MessageBox.Show(err.Message); }
[/codesyntax]
您终于更新了
呵呵