diff --git a/src/Umbraco.Web/Editors/TinyMceController.cs b/src/Umbraco.Web/Editors/TinyMceController.cs index 7ed71f0268..0951b88443 100644 --- a/src/Umbraco.Web/Editors/TinyMceController.cs +++ b/src/Umbraco.Web/Editors/TinyMceController.cs @@ -1,32 +1,41 @@ -using System.Net; -using System.Net.Http; -using System.Web.Http; -using Umbraco.Core.Services; -using Umbraco.Web.WebApi; -using Umbraco.Core; -using Umbraco.Web.Mvc; -using Umbraco.Core.IO; +using System; using System.IO; -using System.Threading.Tasks; -using Umbraco.Web.Composing; -using Umbraco.Core.Configuration.UmbracoSettings; using System.Linq; -using System; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; +using System.Web.Http; +using Umbraco.Core; +using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.IO; +using Umbraco.Core.Logging; +using Umbraco.Core.Services; +using Umbraco.Web.Composing; +using Umbraco.Web.Mvc; +using Umbraco.Web.WebApi; +using Umbraco.Web.WebApi.Filters; +using Constants = Umbraco.Core.Constants; namespace Umbraco.Web.Editors { [PluginController("UmbracoApi")] + [UmbracoApplicationAuthorize( + Constants.Applications.Content, + Constants.Applications.Media, + Constants.Applications.Members)] public class TinyMceController : UmbracoAuthorizedApiController { private IMediaService _mediaService; private IContentTypeBaseServiceProvider _contentTypeBaseServiceProvider; + public TinyMceController(IMediaService mediaService, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider) { _mediaService = mediaService; _contentTypeBaseServiceProvider = contentTypeBaseServiceProvider; } + [UmbracoApplicationAuthorize(Constants.Applications.Content)] [HttpPost] public async Task UploadImage() { @@ -91,8 +100,9 @@ namespace Umbraco.Web.Editors } catch (Exception ex) { - // Could be a file permission ex - throw; + // IOException, PathTooLong, DirectoryNotFound, UnathorizedAccess + Logger.Error(ex, "Error when trying to move {CurrentFilePath} to {NewFilePath}", currentFile, newFilePath); + return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, $"Error when trying to move {currentFile} to {newFilePath}", ex); } return Request.CreateResponse(HttpStatusCode.OK, new { tmpLocation = relativeNewFilePath });