Merge branch 'temp-U4-7178-media-library' of https://github.com/umbraco/Umbraco-CMS into temp-U4-7178-media-library
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
<system.web>
|
||||
<customErrors mode="RemoteOnly" />
|
||||
<trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
|
||||
<httpRuntime requestValidationMode="2.0" enableVersionHeader="false" targetFramework="4.5" />
|
||||
<httpRuntime requestValidationMode="2.0" enableVersionHeader="false" targetFramework="4.5" maxRequestLength="1048576" />
|
||||
<!--
|
||||
If you are deploying to a cloud environment that has multiple web server instances,
|
||||
you should change session state mode from "InProc" to "Custom". In addition,
|
||||
@@ -222,6 +222,13 @@
|
||||
<remove name="X-Powered-By" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
|
||||
<!-- Increase the default upload file size limit -->
|
||||
<security>
|
||||
<requestFiltering>
|
||||
<requestLimits maxAllowedContentLength="1073741824" />
|
||||
</requestFiltering>
|
||||
</security>
|
||||
|
||||
</system.webServer>
|
||||
|
||||
|
||||
@@ -123,15 +123,15 @@ namespace Umbraco.Web.Editors
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[FilterAllowedOutgoingMedia(typeof(IEnumerable<MediaItemDisplay>))]
|
||||
public IEnumerable<MediaItemDisplay> GetChildFolders(int id = -1)
|
||||
[FilterAllowedOutgoingMedia(typeof(IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>>))]
|
||||
public IEnumerable<ContentItemBasic<ContentPropertyBasic, IMedia>> 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<IMedia, MediaItemDisplay>);
|
||||
return children.Where(x => folderTypes.Contains(x.ContentTypeId)).Select(Mapper.Map<IMedia, ContentItemBasic<ContentPropertyBasic, IMedia>>);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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<string, object>(),
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user