Exemplo n.º 1
0
        public JsonResult UploadFile()
        {
            string titleJson  = Request.Form.ToString();
            string videoTitle = StringOps.ExtractJsonValue(titleJson);


            HttpPostedFileBase file = Request.Files[0];

            VDXFile vdxFile = new VDXFile(file, videoTitle, "admin", DateTime.Now.ToString());

            if (!VDXFileValidator.isVideoFormat(vdxFile))
            {
                return(Json("Upload failed: That is not a video."));
            }
            else
            {
                bool uploadStatus = vdxFile.writeUpload(this.HttpContext);
                if (uploadStatus)
                {
                    Task.Factory.StartNew(() =>
                    {
                        VDXFile toConvert = vdxFile;
                        toConvert.executeConversion();
                    });
                    return(Json(file.FileName + " has been uploaded successfully!"));
                }
                else
                {
                    return(Json("Upload failed: The server was unable to process the request."));
                }
            }
        }