I am doing a very simple test with uploading a JPEG file by setting maxsizeindatabase in sitecore.config to 1 MB and trying to upload a ~4MB file giving me a syntax error as below-

<setting name="Media.MaxSizeInDatabase" value="1MB" />

enter image description here

This is a fresh Sitecore 8.2 Update 5 instance installed on my machine and tried uploading a image, browsing a image field --> image dialog box. Images below 1mb(below maxsizeindatabase) uploads successfully without any errors.

The same image when I try from media library give me a proper message- enter image description here

If anybody knows the resolution on this issue and can share here will be very grateful. thanks

1 Answer 1


This is a bug in Sitecore, you should raise it with Sitecore Support and request a fix.

The problem is the response that is being returned by the CheckSize processor is incorrect and not what the expected response.

You can workaround it yourself by replacing the CheckSize processor in uiUpload pipeline and then only setting the UiResponseHandler if the calling code was not from the dialog used by the Experience Editor:

namespace MyProject.MediaUpload.Pipelines.Upload
  public class CheckSize : UploadProcessor
    public void Process(UploadArgs args)
      Assert.ArgumentNotNull(args, nameof(args));
      if (args.Destination == UploadDestination.File)
      foreach (string file1 in args.Files)
        HttpPostedFile file2 = args.Files[file1];
        if (!string.IsNullOrEmpty(file2.FileName))
          if (UploadProcessor.IsUnpack(args, file2))
            // copy/paste from default Sitecore processor. Unpack option not available from Experience Editor.
          else if ((long)file2.ContentLength > Settings.Media.MaxSizeInDatabase)
            string fileName = file2.FileName;
            // **FIX**: Add a check and do not send the UiResponseHandler if the caller is from the Experience Editor uploader
            if (HttpContext.Current.Request.Url.AbsolutePath != "/sitecore/shell/api/sitecore/Media/Upload")
            args.ErrorText = string.Format("The file \"{0}\" is too big to be uploaded. The maximum size for uploading files is {1}.", (object)fileName, (object)MainUtil.FormatSize(Settings.Media.MaxSizeInDatabase));

And then patch this in replacing the existing processor:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
        <processor mode="on" type="MyProject.MediaUpload.Pipelines.Upload.CheckSize, MyProject.MediaUpload"
                   patch:instead="processor[@type='Sitecore.Pipelines.Upload.CheckSize, Sitecore.Kernel']" />

The code is an exact copy of the default CheckSize processor expect for the line marked with FIX that checks how the upload was called, which is different in the Experience Editor and Content Editor.

Note for brevity the code that checks the content of zip files that need to be unpacked has not been included, you need to make the same change to that part of the code (use dotPeek or similar to check the decompiled code)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.