When an editor is uploading an image, a new folder is created in a specific directory (a sub-directory in another sub-directory of the root folder) and different sizes of the image are created and stored in the folder.
My problem is that I will not see the folder in the asset pane unless I reload the page. I am wondering what part of the code is messing up or if it is the location that I am trying to create the new folder.
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
//where new Models.Media.ImageFile().MediaFolder is the content reference of folder that the new folder should be created
var contentAssetFolder = contentRepository.GetDefault<ContentAssetFolder>(new Models.Media.ImageFile().MediaFolder);
contentAssetFolder.Name = content.Name.Substring(0, Path.GetExtension(content.Name).Length) + "_" + System.DateTime.Now.ToString("M-d-yy");
return contentRepository.Save(contentAssetFolder, SaveAction.Publish, AccessLevel.NoAccess);
If it appears after reload, it's probably correct code but that the tree structure in assets pane is cached until you do a full reload of page?
Not sure how to invalidate that cache though.
Hmm, I think I will refresh the cache after the folder is created just to see whether or not this is the problem.
Yes, A full reload is required after adding and removing anything using code in the Episerver CMS.
While I am still working on the cache refresh, hey Ravindra can you explain why the page needs to be refreshed! It would help me find a way around this situation.
And I think refreshing the page will do the same for you.
Yep, I came to the same conclusion about having to use Dojo. I was just unclear how the server-side communicated with the UI, if it is via the database then I should be halfway there on developing a solution. Thanks, Ravindra, if you have an example of a simple update then that would help as well!
Great post. It was much needed. Love your simplistic style of explanation. :)
When I finally develop a solution I will post it here, but in the meantime know that the Dojo direction is most likely the right one. Just need to figure out how the backend and Dojo communicates' and if it is event-driven.