1

I'm getting the following message when uploading a file to the Media Library:

The file "xxxx.jpg" is too big to be uploaded.
The maximum size of a file that can be uploaded is -205,824 bytes.

I've tried to max every setting on the web.config, but I have the same result: https://blog.horizontalintegration.com/2012/04/20/sitecore-media-library-upload-errors/

What strikes me is where is that negative value coming from?

EDIT

I've decompiled the dll where this error is being thrown: Sitecore.Shell.Applications.FlashUpload.Simple.

The error is being thrown here:

long databaseUploadSize = Settings.Upload.MaximumDatabaseUploadSize;
if ((long) num > databaseUploadSize)
{
    string text = Translate.Text("The file \"{0}\" is too big to be uploaded.\n\nThe maximum size of a file that can be uploaded is {1}.", (object) filename, (object) MainUtil.FormatSize(databaseUploadSize));
    this.WarningMessage = text;
    SheerResponse.Alert(text);
}

Apparently there is something wrong when Sitecore tries to read the Media settings. I've tried to modify them but no luck. It seems they are being read from somewhere else or it is not being able to read them from the config file.

databaseUploadSize has a negative number.

6
  • 1
    How big is your file? Commented Nov 22, 2016 at 18:52
  • It happens with any file size, so the size of the file being uploaded seems unrelated to the issue.
    – Mat-Tap
    Commented Nov 22, 2016 at 18:53
  • 1
    Can you check this setting : <setting name="Media.MaxSizeInMemory" value="60MB" /> Commented Nov 22, 2016 at 19:44
  • 1
    check /sitecore/admin/showconfig.aspx for this setting value. maybe there is a patch file which changes the value?
    – Marek Musielak
    Commented Nov 22, 2016 at 21:07
  • 2
    @matap Please create an answer of your solution and mark it as answered afterwards. This makes it clear to everyone that a solution is found.
    – Thomas D
    Commented Nov 23, 2016 at 9:41

1 Answer 1

1

Found the issue. httpRuntime maxRequestLength="2147483647"

That value should be set on Kb and not bytes, and Sitecore is doing the following calculation:

  public static long EffectiveMaxRequestLengthBytes
  {
    get
    {
      return (long) ((Settings.Runtime.MaxRequestLength - 200) * 1024);
    }
  }

And then:

  public static long MaximumDatabaseUploadSize
  {
    get
    {
      return Math.Min(Settings.Media.MaxSizeInDatabase, Settings.Runtime.EffectiveMaxRequestLengthBytes);
    }
  }
3
  • 1
    Just curious .. what is the significance of -200 in that calculation.. Understanding multiplication by 1024 is quite straight forward but I am having a hard time understanding why 200 is subtracted? Is it countering for header / footer of the packet or something? Commented Nov 23, 2016 at 14:49
  • Yeah, those magic numbers are hard to guess. I also couldn't figure out why -200. Also, they should have cast the variable to long and not the operation result.
    – Mat-Tap
    Commented Nov 23, 2016 at 15:59
  • Yes, anyways glad you found the answer :) Commented Nov 23, 2016 at 16:17

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.