November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Oh... forgot to write it under epi version. CloudFront (Amazon) with S3 bucket.
Will edit main post to include this info there too
Yes, you want to call the CloudFront API when the file is changed somehow:
public class WebInit : EPiServer.Framework.IInitializableModule { public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context) { if (Utilities.IsProdServer) //only in production { DataFactory.Instance.SavedContent += PurgeContent; DataFactory.Instance.MovedContent += PurgeContent; DataFactory.Instance.DeletedContent += PurgeContent; } } private void PurgeContent(object sender, ContentEventArgs e) { var cdnPurgeContent = false; bool.TryParse(ConfigurationManager.AppSettings["CDNPurgeContent"], out cdnPurgeContent); // a flag in web.config, not in dev or test if (e != null && cdnPurgeContent) { if (e.Content is MediaData) // here only media { //Send to CDN try { string purge_pattern = e.Content.Name; PurgeCDN(UrlResolver.Current.GetUrl(e.Content.ContentLink)); } catch (Exception ex) { //Log Utilities.Instance.Logger("Error PurgeContent, purge against CDN: ", ex); } } } }
Then build your "PurgeCDN" against the API of your CDN, it probably looks something like this:
var values = new NameValueCollection(); values["site_id"] = siteid; //iggesund values["api_id"] = api_id; values["api_key"] = api_key; values["purge_pattern"] = url; var response = client.UploadValues(CDN_URL, values); var responseString = Encoding.Default.GetString(response);
If you are using some custom blob provider than this can be managed from blob provider also. What blob provider are you using?
By disassembling episerver.amazo.9.2.0, I can see method implementation of Amazon Blob provider, where _StorageClient is IAmazonS3
public override void Delete(Uri id)
{
Blob.ValidateIdentifier(id, new bool?());
this._storageClient.DeleteObject(this.ClientConfiguration.BucketName, AmazonBlob.ConvertToKey(id));
}
On Clearing the trash This method should be called and delete the image from Amazon S3 or this may be calling on running remove abodoned blobs job.
Try once running the Job "Remove abandoned blobs" from admin also, does it clear your blobs?
Hi!
I have some content which I wanna remove (it will not be used on any pages etc) from CDN. Is it possible to remove those images through cms panel or at least from code? Moving items to trash (and empty trash) not removing items from CDN.
Episerver v9 here
CDN: CloudFront (Amazon) with S3 bucket