Beispiel #1
0
 public bool UploadVideo(HttpPostedFile postFile, bool isConvert, string savePath, int? configSize, bool isGetImg, bool isGetSpan, out VideoModel model, string extend)
 {
     model = new VideoModel();
     if (postFile == null)
     {
         return false;
     }
     if (configSize.HasValue && (postFile.ContentLength > configSize.Value))
     {
         this._errorMessage = "上传文件过大";
         return false;
     }
     ConfigHelper.GetConfigString("UploadFolder");
     string str = Path.GetExtension(postFile.FileName).ToLower();
     string str2 = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + str;
     string path = HttpContext.Current.Server.MapPath("/" + savePath);
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     string str4 = savePath + str2;
     postFile.SaveAs(HttpContext.Current.Server.MapPath(str4));
     model.SavePath = str4;
     if (isConvert)
     {
         string str5 = Path.ChangeExtension(str4, extend);
         string destFileName = Path.Combine(path, Path.ChangeExtension(postFile.FileName, extend));
         this.ConvertFlv(HttpContext.Current.Server.MapPath(str4), destFileName);
         model.SavePath = str5;
     }
     if (isGetImg)
     {
         string str7 = Path.ChangeExtension(str4, ".jpg");
         string str8 = Path.Combine(HttpContext.Current.Server.MapPath(str4), Path.ChangeExtension(str4, ".jpg"));
         this.CreateThumb(HttpContext.Current.Server.MapPath(str4), HttpContext.Current.Server.MapPath(str8));
         model.ImgPath = str7;
     }
     if (isGetSpan)
     {
         TimeSpan videoTotalTime = this.GetVideoTotalTime(HttpContext.Current.Server.MapPath(str4));
         int num = TimeParser.TimeToSecond(videoTotalTime.Hours, videoTotalTime.Minutes, videoTotalTime.Seconds);
         model.VideoSpan = num;
     }
     return true;
 }
 private void VideoAction(HttpRequest Request, HttpResponse Response)
 {
     HttpPostedFile postFile = Request.Files["Filedata"];
     Response.Charset = "utf-8";
     ConvertVideo video = new ConvertVideo();
     VideoModel model = new VideoModel();
     string valueByCache = ConfigSystem.GetValueByCache("UploadVideoUrl");
     JsonObject obj2 = new JsonObject();
     if (video.UploadVideo(postFile, false, valueByCache, null, false, false, out model, ".swf"))
     {
         obj2.Accumulate("Status", "OK");
         obj2.Accumulate("SavePath", model.SavePath);
         Response.Write("1|" + obj2.ToString());
     }
     else
     {
         obj2.Accumulate("Status", "Failed");
         obj2.Accumulate("ErrorMessage", video.errorMessage);
         Response.Write("0|" + obj2.ToString());
     }
 }