SaaS CMS has officially launched! Learn more now.

How to bulk import files in EPiServer CMS


How to bulk import files in EPiServer CMS from batch file or something similar to that.?

Jun 13, 2016 9:02
Jun 13, 2016 9:38

thanks  Dejan Caric any API that can automate the process of upload?

Jun 13, 2016 9:57

I posted a link to the API you can.

Where do you want to upload the files?

Are they zipped? Do you have to upload them to EPi first, or is it ok to place them in a shared folder and execute the import script?

A long time ago, I wrote a blog post on how I imported content from some legacy system into EPi:

I received exported content in the XML format. XML files were zipped:

<?xml version="1.0" encoding="ISO-8859-1"?>
  <article id="XXX" lastmodified="2010-06-12 11:57:22.0" publishdate="2010-06-12 11:57:22.0">
    <field name="TITLE">Article 1</field>
	<field name="PREAMBLE">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</field>
	<field name="MAINBODY">
		<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
		<p>Pellentesque blandit tincidunt porta.</p>
		<p>Etiam a leo in eros consequat bibendum ut a nibh.</p>
		<p>Aliquam augue orci, vestibulum at sollicitudin at, malesuada non neque.</p>
	<field name="ARTICLEIMAGE"></field>

I wrote a tool in admin mode that extracts the ZIP file, fetches the image from the internet, and creates a new page in the Archive folder.

Hope it helps.

Jun 13, 2016 10:10

i need to upload directly to "Test" folder under "for alll sites".

Jun 13, 2016 11:36

This was written on top of the Alloy site so you may need to change some stuff

var contentAssetHelper = ServiceLocator.Current.GetInstance<ContentAssetHelper>();
                // get an existing content asset folder or create a new one
                var assetsFolder = contentAssetHelper.GetOrCreateAssetFolder(new ContentReference(assetfolderid));
                var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
                var blobFactory = ServiceLocator.Current.GetInstance<EPiServer.Framework.Blobs.BlobFactory>();
                string name = "";
                string ext = "";
 file = contentRepository.GetDefault<ImageFile>(assetsFolder.ContentLink);
                    name = url.Substring(url.LastIndexOf('/') + 1);
                    ext = name.Substring(name.IndexOf('.'));
                    name = url.Replace(ext, "").Trim();
file.Name = name;
                var blob = blobFactory.CreateBlob(file.BinaryDataContainer, "." + ext);
                var data = GetData(url);
                blob.Write(new System.IO.MemoryStream(data));
                file.BinaryData = blob;
                var fileRef = contentRepository.Save(file, EPiServer.DataAccess.SaveAction.Publish);
private byte[] GetData(string url)
                if (url.StartsWith("/"))
                    url = "" + url;
                using (var client = new System.Net.WebClient())
                    byte[] data = client.DownloadData(new Uri(url));
                    return data;
            catch (Exception ex)
                return null;
Jun 13, 2016 19:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.