Shailesh
Shailesh

Reputation: 544

WFFM Image Uploaded event Sitecore 8

I have to execute some custom operations once the WFFM File Upload Item is uploaded in Sitecore Media Library.

How I can get the uploaded WFFM media Item in C#. Which Event/Processor/Pipeline/Config needs to add/update .

I am using below code , it works when i uploaded media manually but not when media comes from Web form Marketer:-

public class ProcessMedia : UploadProcessor
{
    public void Process(UploadArgs args)
    {
    }
}

Upvotes: 2

Views: 306

Answers (1)

jammykam
jammykam

Reputation: 17000

You can add a custom processor to the formUploadFile pipeline, the default definition of which can be found in Sitecore.Forms.config.

public class ProcessMedia
{
    public void Process(FormUploadFileArgs args)
    {
        var itemUri = ItemUri.Parse(args.Result);
        var item = Sitecore.Data.Database.GetItem(itemUri);
        // do some stuff...
    }
}

And then patch your processor in:

<sitecore>
  <pipelines>
    <formUploadFile>
      <processor type="MyCustomProject.Forms.Pipelines.ProcessMedia, MyCustomProject.Forms" />
    </formUploadFile>
  </pipelines>  
</sitecore>

The processor will be patched in after Sitecore.Form.Core.Pipelines.FormUploadFile.Save which is the pipeline responsible for saving files to the Media Library in WFFM.

Upvotes: 2

Related Questions