Issue while programmatically inserting Media Items

Sitecore has described how to create media items by yourself on SDN a while ago. Some how this code was broken while uploading JPG-files larger then 100kb. As I’m currently working on the location fo our customer and they’ve got a lot of network overhead(they are using Novell all over the place…) and the exception told me that the Uploaded file was closed, I decided to check the limits configured in our Web.config.

The httpRuntime Element has a lot of settings which influence the way they are connected to the end-user. I’ve played a little with the maxRequestLength and executionTimeOut. But unfortunetely it didn’t work. Digging in my memory about the specific problem, I remembert that JPG is like, every image format, block based. This might could have something to do with the issue.
There’s a requestLengthDiskThreshold in the httpRuntime. The default size is extremely low(256bytes!). After changing this value to 1kb(1024), it worked again like a charm.

So when you have some issues uploading. Try to add the requestLengthDiskThreshold-parameter to your web.config! I’ll ask the Sitecore Documentation team to add this to the page mentioned above.

5 thoughts on “Issue while programmatically inserting Media Items”

  1. ops.. my previous comment was posted without the code.. Another try:
    httpRuntime maxRequestLength=”16384″ executionTimeout=”600″ requestLengthDiskThreshold=”1024″

  2. Hello Alexander,

    You are totally right. It is configured in that way in our Web.config.
    Thank you for your quick action.

    – Alex

Comments are closed.