November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
If you have a lot of files, maybe the easiest way is to do it by code: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/9/Content/Assets-and-media/Working-with-media/
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: http://www.dcaric.com/blog/importing-archived-articles-from-legacy-system-into-episerver-cms
I received exported content in the XML format. XML files were zipped:
<?xml version="1.0" encoding="ISO-8859-1"?> <io> <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> <field name="ARTICLEIMAGE">http://dummyimage.com/600x400/3978f7/000000.png</field> </article> </io>
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.
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) { try { if (url.StartsWith("/")) { url = "https://portal.ektron.com" + url; } using (var client = new System.Net.WebClient()) { byte[] data = client.DownloadData(new Uri(url)); return data; } } catch (Exception ex) { return null; } }
How to bulk import files in EPiServer CMS from batch file or something similar to that.?