November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
If you want to delete all blobs that is related to a content item then you can use
//Prefer constructor injection if possible var blobFactory = ServiceLocator.Current.GetInstance<BlobFactory>(); blobFactory.Delete(Blob.GetContainerIdentifier(content.ContentGuid));
Note however that if you then go back to a previous version of the content then the associated blob with that version will not exist.
Thanks Björn.
My intention is to have the Published version of each GenericMedia (file) to remain.
Have you any idea on how your approach towards creating blobs on disk in EPiServer is to work.
I thought you had a scenario where you is about to publish a new version, then my thought you could first remove every existing blob and then publish the new one (which leaves you with one). Otherwise if you want more control you can stick with your previously suggested code.
Hi
We have an issue regarding diskstorage on our webbserver.
We have an importjobb which imports files from disk to EPiServer as GenericMedia. This importjob runs quit frequently and we would like to erase Previous versions of the blobs from disk.
The problem is that all of the blobs in the blobscontainer are not erased!? When running the code in an Alloy CMS 9.6 it works.
At the customers produktionenvironment we had the default uiMaxVersions set to 20 but since a month ago we decreased it to 4. I have noticed that this settings only is a UI setting, there will be a new blob for every version of the file dispite what is set for uiMaxVersions.
The code running for the job look like this:
private static List ProcessFiles(IContentRepository contentRepository, IContentVersionRepository versionRepository, IEnumerable genericFiles, List blobsDeleted)(version.ContentLink).CreateWritableClone() as GenericMedia;
{
foreach (var file in genericFiles)
{
if (file is GenericMedia)
{
var versionList = versionRepository.List(file.ContentLink);
foreach (var version in versionList)
{
if (version.Status.ToString() == "PreviouslyPublished")
{
try
{
//Getta en GenericFileVersion from version
var versionGenericFile = contentRepository.Get
BlobFactory.Instance.Delete(versionGenericFile.BinaryData.ID);
DataFactory.Instance.DeleteVersion(versionGenericFile.ContentLink, EPiServer.Security.AccessLevel.NoAccess);
blobsDeleted.Add(versionGenericFile.Name);
}
catch (Exception e)
{
var exception = e.Message;
if (e.InnerException != null)
exception = e.InnerException.ToString();
continue;
}
}
}
}
}
return blobsDeleted;
}
Is there any other way to delete all provious versions for a file?