public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Charset = "utf-8"; HttpPostedFile file = context.Request.Files["file"]; string uploadPath = HttpContext.Current.Server.MapPath("~/Video/"); if (file != null) { if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } string name = System.Guid.NewGuid().ToString() + ".mp4"; string video_title = context.Request["video_title"]; string video_des = context.Request["video_des"]; string user_id = context.Request["user_id"]; VideoModel video = new VideoModel(name, video_title, "\\\\Video\\\\" + name, user_id, video_des); VideoDao dao = Factory.Get(new VideoDao()); dao.Insert(video); file.SaveAs(uploadPath + name); Tool.CatchImg(HttpContext.Current.Server.MapPath("../"), name, "240*180", "1"); //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失 context.Response.Write("1"); } else { context.Response.Write("0"); } }
public async Task <WebResult> Post([FromBody] BaseDanmuDataIn data) { if (string.IsNullOrWhiteSpace(data.Id) || string.IsNullOrWhiteSpace(data.Text)) { return(new WebResult(1)); } data.Ip = IPAddress.TryParse(Request.Headers["X-Real-IP"], out var ip) ? ip : Request.HttpContext.Connection.RemoteIpAddress; data.Referer ??= Request.Headers["Referer"].FirstOrDefault(); var video = VideoDao.Insert(data.Id, new Uri(data.Referer ?? string.Empty)); var danmu = new DanmuTable { Vid = data.Id, Data = data, Ip = data.Ip, Video = video }; var result = await DanmuDao.InsertDanmuAsync(danmu); return(new WebResult(result ? 0 : 1)); }