New to composite C1, some questions

Topics: Feature requests, General
Jul 2, 2011 at 1:37 AM
Edited Jul 2, 2011 at 2:33 AM



I have just deployed Composite C1. However, I'd like to know the following:


1) How can I upload documents to the site via the API? In my case, .rar files. And then I want to make some sort of list with all the documents, downloadable.

2) Relating to the above, this would need to work on the same server the code may be executed from, and to remote servers (in other words, content deployment).

3) Can C1 cache pages?

4) What is the roadmap?



Jul 4, 2011 at 3:00 PM

There is unfortunatly no official API for adding media to the mediaarchive, but i've needed it before and used a few hours to dig this code up from the internal C1 form where you upload images through

IMediaFileStore store = DataFacade.GetData<IMediaFileStore>(x => x.Id == this.StoreId).First();

var uploadedFile = some_file;

WorkflowMediaFile mediaFile = new WorkflowMediaFile();
mediaFile.FileName = "some name";
mediaFile.FolderPath = "path to folder";
mediaFile.Title = "title";
mediaFile.Description = "description";
mediaFile.Culture = C1Console.Users.UserSettings.CultureInfo.Name;
mediaFile.Length = uploadedFile.ContentLength;
mediaFile.MimeType = MimeTypeInfo.GetCanonical(uploadedFile.ContentType);

if (mediaFile.MimeType == MimeTypeInfo.Default)
   mediaFile.MimeType = MimeTypeInfo.GetCanonicalFromExtension(System.IO.Path.GetExtension(mediaFile.FileName));

using (System.IO.Stream readStream = uploadedFile.FileStream)
   using (System.IO.Stream writeStream = mediaFile.GetNewWriteStream())

IMediaFile addedFile = DataFacade.AddNew<IMediaFile>(mediaFile, store.DataSourceId.ProviderName);
Jul 4, 2011 at 11:24 PM

Thanks for the reply.

Jul 5, 2011 at 7:48 AM

>> Can C1 cache pages?

It can and it does. It is ASP.NET full page caching, if you open file /Renderers/Page.aspx, you'll see a line


<%@ OutputCache Duration="60" VaryByParam="*" VaryByCustom="C1Page" %>


By default all pages are cached for 1 minute (on server, and on client machines through a http response header cookie. This caching is disabled for logged-in users.

If full page caching isn't an option, one can use build in page profiler (log in, go to a page, add "?c1mode=perf" to url) to find problem areas. Then either use Composite.Utils.Caching.PageObjectCache function for caching layout parts, or optimize C#/LINQ/XSLT/SQL code behind functionality. 

Jul 5, 2011 at 2:49 PM

>> What is the roadmap?

At the moment we're in the process of evaluating and improving the Composite C1 starter experience (to make it even better :) ).

That includes more themes, better end-user experience, more hosting options - including extended Windows Azure integration.

After summer we expect to publish the roadmap for the upcoming 6-12 month.

Apr 18, 2013 at 4:03 PM
Edited Apr 18, 2013 at 4:17 PM
Does anyone know how to create folders in the media library programmatically? Is it even possible?

EDIT Funny enough I stumbled upon it 5 min after posting this. See below if anyone is interested. There might be a better way though.
IMediaFileFolder folder = DataFacade.BuildNew<IMediaFileFolder>();
folder.Title = "Example";
folder.Path = "/Example";
folder.StoreId = store.Id;

IMediaFolder newFolder = DataFacade.AddNew<IMediaFileFolder>(folder, store.DataSourceId.ProviderName);