public WrappedJsonResult UploadSingleFile(HttpPostedFileWrapper uploadFile, string SelectedFolderId, string RootFolderType) { var rootFolderType = (MediaType)Enum.Parse(typeof(MediaType), RootFolderType); if (uploadFile != null && FileFormatIsValid(rootFolderType, uploadFile.ContentType)) { UploadFileRequest request = new UploadFileRequest { RootFolderId = SelectedFolderId.ToGuidOrDefault(), Type = rootFolderType, FileLength = uploadFile.ContentLength, FileName = uploadFile.FileName, FileStream = uploadFile.InputStream }; var media = GetCommand<UploadCommand>().ExecuteCommand(request); if (media != null) { return new WrappedJsonResult { Data = new { Success = true, Id = media.Id, fileName = media.OriginalFileName, fileSize = media.Size, Version = media.Version, Type = request.Type, IsProcessing = !media.IsUploaded.HasValue, IsFailed = media.IsUploaded == false, } }; } } List<string> messages = new List<string>(); messages.AddRange(Messages.Error); return new WrappedJsonResult { Data = new { Success = false, Messages = messages.ToArray() } }; }
public ActionResult UploadMedia(HttpPostedFileBase file) { var rootFolderId = Request.Form["rootFolderId"].ToGuidOrDefault(); var reuploadMediaId = Request.Form["reuploadMediaId"].ToGuidOrDefault(); var shouldOverride = Request.Form["shouldOverride"].ToBoolOrDefault(); var rootFolderType = (MediaType)Enum.Parse(typeof(MediaType), Request.Form["rootFolderType"]); if (file != null && FileFormatIsValid(rootFolderType, file.ContentType)) { UploadFileRequest request = new UploadFileRequest { RootFolderId = rootFolderId, Type = rootFolderType, FileLength = file.ContentLength, FileName = file.FileName, FileStream = file.InputStream, ReuploadMediaId = reuploadMediaId, ShouldOverride = shouldOverride }; var media = GetCommand<UploadCommand>().ExecuteCommand(request); if (media != null) { return WireJson(true, new { FileId = media.Id, Version = media.Version, Type = (int)rootFolderType, IsProcessing = !media.IsUploaded.HasValue, IsFailed = media.IsUploaded == false, }); } } return Json(new WireJson(false)); }
public ActionResult UploadMedia(HttpPostedFileBase file) { var rootFolderId = Request.Form["rootFolderId"].ToGuidOrDefault(); var rootFolderType = (MediaType)Enum.Parse(typeof(MediaType), Request.Form["rootFolderType"]); UploadFileRequest request = new UploadFileRequest(); request.RootFolderId = rootFolderId; request.Type = rootFolderType; request.FileLength = file.ContentLength; request.FileName = file.FileName; request.FileStream = file.InputStream; var media = GetCommand<UploadCommand>().ExecuteCommand(request); if (media != null) { return Json( new WireJson( true, new { FileId = media.Id, Version = media.Version, Type = (int)rootFolderType })); } return Json(new WireJson(false)); }