From 53fdc801f3c6fad7d8520dc78b160c996b1a7161 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Fri, 16 Oct 2015 11:26:04 +0200 Subject: [PATCH 1/3] Return basic entity instead of display entity --- src/Umbraco.Web/Editors/MediaController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index c3a181eb9b..dcea71669b 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -123,15 +123,15 @@ namespace Umbraco.Web.Editors /// /// /// - [FilterAllowedOutgoingMedia(typeof(IEnumerable))] - public IEnumerable GetChildFolders(int id = -1) + [FilterAllowedOutgoingMedia(typeof(IEnumerable>))] + public IEnumerable> GetChildFolders(int id = -1) { //Suggested convention for folder mediatypes - we can make this more or less complicated as long as we document it... //if you create a media type, which has an alias that ends with ...Folder then its a folder: ex: "secureFolder", "bannerFolder", "Folder" var folderTypes = Services.ContentTypeService.GetAllMediaTypes().Where(x => x.Alias.EndsWith("Folder")).Select(x => x.Id); var children = (id < 0) ? Services.MediaService.GetRootMedia() : Services.MediaService.GetById(id).Children(); - return children.Where(x => folderTypes.Contains(x.ContentTypeId)).Select(Mapper.Map); + return children.Where(x => folderTypes.Contains(x.ContentTypeId)).Select(Mapper.Map>); } /// From f7c2f779c23f888d66bc19343157cb12707d78e0 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Fri, 16 Oct 2015 12:48:34 +0200 Subject: [PATCH 2/3] Fixed: U4-7264 Support for folder upload part of the media library polish, when a folder is dragged to the view, it will check if folders exist, and create if needed, this makes it easier to replicate a folder structure when uploading. --- src/Umbraco.Web/Editors/MediaController.cs | 38 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index dcea71669b..68deecbcbf 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -424,7 +424,7 @@ namespace Umbraco.Web.Editors { return Request.CreateValidationErrorResponse("The request was not formatted correctly, the currentFolder is not an integer"); } - + //ensure the user has access to this folder by parent id! if (CheckPermissions( new Dictionary(), @@ -438,9 +438,42 @@ namespace Umbraco.Web.Editors Services.TextService.Localize("speechBubbles/invalidUserPermissionsText"), SpeechBubbleIcon.Warning))); } - + var tempFiles = new PostedFiles(); + var mediaService = ApplicationContext.Services.MediaService; + + //in case we pass a path with a folder in it, we will create it and upload media to it. + string path; + if (result.FormData.ContainsKey("path")) + { + var folders = result.FormData["path"].Split('/'); + + for (int i = 0; i < folders.Length-1; i++) + { + var folderName = folders[i]; + + //get current parent + var mediaRoot = mediaService.GetById(parentId); + + //look for matching folder + var folderMediaItem = mediaRoot.Children().FirstOrDefault(x => x.Name == folderName && x.ContentType.Alias == Core.Constants.Conventions.MediaTypes.Folder); + if (folderMediaItem == null) + { + //if null, create a folder + folderMediaItem = mediaService.CreateMedia(folderName, mediaRoot, Constants.Conventions.MediaTypes.Folder); + mediaService.Save(folderMediaItem); + + //set the media root to the folder id so uploaded files will end there. + parentId = folderMediaItem.Id; + } + else + { + parentId = folderMediaItem.Id; + } + } + } + //get the files foreach (var file in result.FileData) { @@ -454,7 +487,6 @@ namespace Umbraco.Web.Editors if (UmbracoConfig.For.UmbracoSettings().Content.ImageFileTypes.Contains(ext)) mediaType = Constants.Conventions.MediaTypes.Image; - var mediaService = ApplicationContext.Services.MediaService; var f = mediaService.CreateMedia(fileName, parentId, mediaType, Security.CurrentUser.Id); var fileInfo = new FileInfo(file.LocalFileName); From b6bbb8e79d6475b9960aade221d6d4fabbec1e63 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Fri, 16 Oct 2015 12:58:08 +0200 Subject: [PATCH 3/3] Related to: U4-7264 Support for folder upload Enable a larger file max size for upload as 4mb is quickly very limiting. --- src/Umbraco.Web.UI/web.Template.config | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 924a5436f8..d7498558f1 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -79,7 +79,7 @@ - + + + + + +