Hi Amol.
It's indeed a way to achieve what you are looking for. Instead of hardcoding the ID of your parent, you could use either ContentReference.SiteBlockFolder, ContentReference.GlobalBlockFolder or the SiteAssetsRoot/GlobalAssetsRoot property of your current SiteDefinition (via ISiteDefinitionRepository)
Two tips to ensure you aren't forgetting some scenarios:
1. Ensure you restrict both the Site specific and the Global asset container. Suppose your authors should be prohibited from uploading PDF assets in the root of any of these.
2. Files can also be specific to a page or block - ensure this scenario is taken in to account as well.
Have a good day and happy holidays!
Casper Aagaard Rasmussen
Thanks Casper :)
Exactly what I was looking for. sometime stuffs are rather simple we make it complicated :D
Hello,
For a business logic in an Episerver 9 CMS site. I have to find out that the media (pdf) uploaded by editor is not directly under the root node i.e. media, it must be under some folder. To acheive this I put in the following but I am uncertain that this will guarentee me the same output in all the environment, however it works in my local environment
var media = content as MediaData; // Getting the data from BlobFactory
var repository = ServiceLocator.Current.GetInstance(); // Get a repository instance
var folder = repository.Get(media.ParentLink); // Get the parent of the current document in context
if (folder.ParentLink.ID != 1) //Check for the Parent of parent
//Do the business logic if not true
is there another better way of doing this?