public ActionResult RenderScreenshots(int id) { // Getting this despite not using it to verify that the member owns this file var project = GetProjectForAuthorizedMember(id); var mediaProvider = new MediaProvider(); var availableFiles = mediaProvider.GetMediaFilesByProjectId(id) .Where(x => x.FileType == FileType.screenshot.FileTypeAsString()).ToList(); foreach (var wikiFile in availableFiles) { wikiFile.Current = project.CurrentReleaseFile == wikiFile.Id.ToString(); } var model = new EditScreenshotModel { AvailableFiles = availableFiles, UploadFile = new ScreenshotModel() }; return(PartialView("~/Views/Partials/Project/EditScreenshots.cshtml", model)); }
public ActionResult AddScreenshot(EditScreenshotModel model) { if (ModelState.IsValid == false) { return(CurrentUmbracoPage()); } // Getting this despite not using it to verify that the member owns this file var project = GetProjectForAuthorizedMember(model.UploadFile.ProjectId); var member = Members.GetCurrentMember(); HttpPostedFile file; using (var target = new MemoryStream()) { model.UploadFile.File.InputStream.CopyTo(target); byte[] data = target.ToArray(); file = ConstructHttpPostedFile(data, model.UploadFile.File.FileName, model.UploadFile.File.ContentType); } var contentService = Services.ContentService; var projectContent = contentService.GetById(project.Id); var wikiFile = WikiFile.Create( model.UploadFile.File.FileName, projectContent.PublishedVersionGuid, member.GetKey(), file, "screenshot", new List <UmbracoVersion> { UmbracoVersion.DefaultVersion() } ); return(RedirectToCurrentUmbracoPage(Request.Url.Query)); }