+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Amazon S3 - Event listening

Amazon S3 - Event listening

3 posts, 0 answered
  1. Tony Bolton
    Tony Bolton avatar
    33 posts
    Registered:
    06 Oct 2009
    09 Oct 2010
    Link to this post
    Hi,

    Sorry for my 3rd post in as many days!

    In my previous configuration I would use global.asax to intercept creation events into particular libraries so that I could generate custom thumbnails etc.  In Application_Start I had the following :

    Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);

    This event does not seem to be triggered now that I've switched to S3 as my library provider.  I've trawled through the net/documentation/reflector to try and see if there is a similar event for S3 but with no luck.

    Could you tell me if there is a way to do this?

    Cheers!
    Tony

  2. Tony Bolton
    Tony Bolton avatar
    33 posts
    Registered:
    06 Oct 2009
    10 Oct 2010
    Link to this post
    Hi,

    Ok I've done a bit more testing, and worked out that I could try and override the Data.AmazonProvider's OnExecuting method by putting my custom code at the top eg :

    protected override void OnExecuting(Telerik.ExecutingEventArgs args, bool fireEvents)
        {
      
            String NEWS_FOLDER = ConfigurationManager.AppSettings["CustomNewsImageFolder"].ToString();
            String EVENTS_FOLDER = ConfigurationManager.AppSettings["CustomEventsImageFolder"].ToString();
      
            // Customised method to generate our bespoke thumbnail etc as required.
            if (!args.Cancel){
                .....<snip>
            }
      
            base.OnExecuting(args, fireEvents);

    I then compiled it into App_Code and changed the provider name to my custom class (CustomAmazonProvider) by setting it in Web.config, like so :

    <add name="Libraries" urlRewriteFormat="~/{LibraryName}/[Name].s3lb"  thumbnailExtension=".tmb" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" applicationName="/Libraries" allowVersioning="True" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="CustomAmazonProvider, App_Code" tagEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Libraries/BatchTagsEditor.ascx" />

    However, I can't use it as I get a 'The given key was not present', which I'm guessing is to do with the code not being part of the Telerik libraries.

    Am I on the right track here - I was so close to sorting it!

    Cheers,
    Tony
  3. Tony Bolton
    Tony Bolton avatar
    33 posts
    Registered:
    06 Oct 2009
    10 Oct 2010
    Link to this post
    Seems I'm getting good at answering my own questions!

    I've sorted it - the above all worked, but in my config file I forgot to add the namespace (ie. "MyNamespace.CustomAmazonProvider, App_Code") hence the key could not be found error.  Realised my mistake when I deliberately sabotaged the type name and still got the same error.

    I'd be interested to hear if this is the route you would have taken, however.

    Thanks,
    Tony
Register for webinar
3 posts, 0 answered