Bug: Sitecore Media Library Issue with Unpacking Zip Archives

Vasiliy Fomichev

In Sitecore Fix Posted

Sitecore 8 seems to have grown up and become more stable, however, once in a while a small bug would creep in. The article covers a bug found in Sitecore 8 Update 3 with Media Library not unpacking zip archives, when that options has been checked in Advanced Upload.


Sitecore Media Library Population Strategy

Sitecore Media Library Advanced Upload

Sitecore Media Library Advanced Upload

Before jumping into the bug and providing a fix, I would like to spend a little time talking about the Media Library; just at a high level, to establish some context. Go ahead and scroll down, if you are here strictly for the bug fix.

One of the tasks that seems to be underestimated in Sitecore development is content population. In turn the most underestimated and overlooked, yet very important task of content population is media upload. An interesting fact is that, yes, it can be painless, if planned correctly from the beginning, however, it can become a real PINA, if done in a rush without any planning and structure in place.

Media Library can get really… really! messy if not taken care of. If the structure has not been defined, or was defined, but it does not make sense to editors; if image fields in content are not set to point to proper locations, if image size, type and dimension validators are not in place and if no regular cleanup and organization is performed, the Media Library can turn into a very dark place, where nobody wants to go to, where things files get forgotten, ghost stories get born…well, you get the picture. Add item buckets on top of all that, and it just becomes a complete mess. Searchable, but a mess. Image URLs could get out of control, which could potentially affect their SEO.

There are a few strategies one could carry out for Media Library structure, and the one I follow has been engraved in me since probably day one of Sitecore training years ago – keep the structure similar to the content tree. This served me well across many Sitecore projects, and editors always found it very helpful. For the sake of this topic not becoming a can of worms, I will just leave this at that.

Now, that we’ve identified the structure, what is the best way to populate it? Well, the best way would vary with each website, circumstances, resources available, data sources…etc. However, the easiest manual way I found is recreating the structure in the file system, then archiving it and uploading it into Sitecore Media Library with the Unpack Zip Archive option checked using Advanced Upload. This option uploads the archive, extracts the contents and reproduces the folder structure with assets. This is easier than uploading images as the content gets populated, and I recommend readers to give it a try in their implementations.


Sitecore 8 Media Library does not Unpack Archives

Being a fan of the Unpack Zip Archive feature of Sitecore Media Library, I was eager to try it in Sitecore 8 to see if anything was changed. Well, this was the time Sitecore decided to play a joke on me and throw a JavaScript error when, it tried to unpack the test archive I created:

Being slammed with the project deliverables, I didn’t have to time to troubleshoot the error and immediately referred to Sitecore Support. As always they were prompt to respond with fix.


How to Fix Sitecore Media Library Issue With Not Unpacking Archives

Sitecore Support replied with the following directions:

  1. Backup the Website\sitecore\shell\Applications\Media\MediaFolder\MediaFolder.js file.
  2. Put the attached MediaFolder.js file to the Website\sitecore\shell\Applications\Media\MediaFolder folder.
  3. Clear your browser cache.

After applying the patch the archives started unpacking as they should. However, what was that caused the issue? I broke out my favorite file and folder comparison tool – Beyond Compare and noticed the following changes in the new MediaFolder.js file:

this.yUploader.upload(file, this.destination, "POST", params);

was changed to

this.yUploader.upload(file, this.destination, params);

So, if you are adventurous enough to have already done some customizations to the file previously, feel free to simply make the changes above manually to the existing file and enjoy the rest of your day!


Hopefully, this post will save many hours of frustration or days of troubleshooting to others, so please share this article, as many developers will thank you. Also remember to comment on this article, especially if you were affected by the same bug and this fix worked for you; please mention the version and revision of Sitecore you experienced the same problem on. Finally, give back by blogging, tweeting, and posting on Sitecore forums about any bugs and fixes you find yourself!




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Vasiliy Fomichev
    April 1, 2016 at 11:57 am

    Hi @@disqus_2gy5HRGFHf:disqus , what’s the revision it was tested on?

  • VC
    March 29, 2016 at 1:54 am

    Fix Not working with Sitecore 8.1.