Downloading the media library folder

Sitecore provides you with the facility to download individual files from the Content Editor. Sometimes, content authors might need to download the whole media library or media files of any selected folders in a ZIP file. In this recipe, you will learn how to use Sitecore APIs to download the whole media library folder along with media metadata.

How to do it…

We will first create a Command class to download the media library folder:

  1. In the SitecoreCookbook project, create a new DownloadMediaLibraryFolder class in the Commands folder and inherit it from the Command class.
  2. Override the Execute() method of the class as follows:
    public override void Execute(CommandContext context) { if (context.Items.Length == 1) { ...

Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.