当前位置: 首页>>代码示例>>C#>>正文


C# Utils.HttpUpload方法代码示例

本文整理汇总了C#中System.Utils.HttpUpload方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.HttpUpload方法的具体用法?C# Utils.HttpUpload怎么用?C# Utils.HttpUpload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Utils的用法示例。


在下文中一共展示了Utils.HttpUpload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: add

 public void add(JabinfoContext context)
 {
     Weixin weixin = new Weixin ();
     Utils util = new Utils ();
     if (!context.IsPost) {
         return;
     }
     context.Post ["uploadId"] = Jabinfo.Help.Basic.JabId;
     string type = context.Post ["type"];
     string fileName = context.Files ["afile"].FileName;
     string model=fileName.Substring(fileName.LastIndexOf('.') + 1);
     Jabinfo.Help.Upload.Save (context.Post ["uploadId"], context.Files["afile"],model);
     string file = Jabinfo.Help.Upload.PysPath (context.Post ["uploadId"],model);
     string url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token="+weixin.GetAccessToken();
     url = url + "&type=" + type;
     string json = util.HttpUpload (url, file);
     context.Post ["mediaId"] = weixin.GetJsonValue (json,"media_id");
     context.Post ["createdAt"] = weixin.GetJsonValue(json,"created_at");
     if (!string.IsNullOrEmpty (weixin.GetJsonValue (json, "errcode"))) {
         context.Jump ("/article/upload/home","无效媒体类型,请重新上传");
         return;
     }
     UploadMapper.I.Insert(context.Post);
     context.Refresh ();
 }
开发者ID:justinfoxmail,项目名称:wxipr,代码行数:25,代码来源:Upload.cs

示例2: upload

 /// <summary>
 /// 上传媒体文件
 /// </summary>
 /// <param name="context">Context.</param>
 /// <param name="articles">Articles.</param>
 public void upload(JabinfoContext context,string articles)
 {
     if (!context.IsPost) {
         context.Variable ["articles"] = articles;
         return;
     }
     Weixin wx = new Weixin ();
     Utils util = new Utils ();
     string[] article =context.Post["articles"].Split (',');
     StringBuilder str = new StringBuilder ("{ \r\n");
     StringBuilder con = new StringBuilder ();
     str.Append (" \"articles\": [ \r\n");
     for (int i = 0; i < article.Length - 1; i++) {
         ArticleVO ar = ArticleMapper.I.Create (article [i]);
         ArticleDetailVO d = ArticleDetailMapper.I.Create (article [i]);
         con.Append("{ \r\n");
         Regex reg = new Regex(@"(?i)</?a\b[^>]*>");    //去掉字符串的<a>标签
         Regex reg1=new Regex(@"<img[^>]*?/>");         //去掉img标签
         Regex reg2=new Regex(@"style=""[^""]*""");     //去掉style标签
         string result = reg.Replace(d.content, "");
         result = reg1.Replace (result, "");
         result = reg2.Replace (result, "");
         string file = Jabinfo.Help.Upload.PysPath (ar.articleId,"jpg");
         string url = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token="+wx.GetAccessToken();
         url = url + "&type=image";
         string json = util.HttpUpload (url, file);
         con.Append (string.Format(" \"thumb_media_id\":\"{0}\", \r\n",wx.GetJsonValue (json,"media_id")));
         con.Append("\"author\":\"" + ar.author.ToString() + "\",");
         con.Append("\"title\":\"" + ar.title.ToString() + "\",");
         con.Append(string.Format(" \"content_source_url\":\"{0}\", \r\n","http://wx.zento.me/article/home/detail/"+ ar.articleId));
         con.Append("\"content\":\"" + Jabinfo.Help.Formate.ClearSpace(result) + "\",");
         con.Append("\"digest\":\"" +  Jabinfo.Help.Formate.ClearSpace(ar.summary) + "\",");
         con.Append (" \"show_cover_pic\":\"0\" \r\n");
         con.Append (" },");
     }
     string mian = con.ToString ();
     string text = mian.Substring (0, mian.Length - 1);
     str.Append (text);
     str.Append ("  ] \r\n");
     str.Append ("} \r\n");
     wx.UpNews (str.ToString (),context.Post["title"]);
     context.Refresh ();
 }
开发者ID:justinfoxmail,项目名称:wxipr,代码行数:48,代码来源:Article.cs


注:本文中的System.Utils.HttpUpload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。