I want to subscribe to an event when a file, preferably images only, as been uploaded.
I’ve tried subscribing to Litium.Media.Events.FileCreated but it doesn’t seem to be triggered when I upload an image in backoffice.
Am I missing something?
Which Litium version are you using? What does your code look like?
I adapted the example from Docs and could hit the break point after uploading a new file in Media.
[Autostart]
public class FileCreatedEventHandler : IDisposable
{
private readonly Litium.Events.ISubscription<Litium.Media.Events.FileCreated> _subscription;
public FileCreatedEventHandler(EventBroker eventBroker)
{
_subscription = eventBroker.Subscribe<Litium.Media.Events.FileCreated>(fileEvent =>
{
var newGuid = fileEvent.Item.SystemId; // caught this break point
});
}
public void Dispose()
{
_subscription.Dispose();
}
}
I did the same thing only I inject a service in the ctor. thanks tho, now I know that I’m not wasting my time trying to fix it.
Yup, I had forgotten to decorate my interface with the attributes needed… smh
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.