5

Does anyone know a way to trigger a script on asset download? Can't find anything in the docs and don't see an obvious trigger condition for that.

2
  • I couldn't find a direct way to do that, but it seems when you select assets and click download a job will be created, so, you could use that, add a trigger on entity creation for M.Job definition, with a condition if the Job.Type is download job, then in the script see how much information you can get from the context. Dec 18, 2020 at 23:16
  • Mohammed, that option could work for mass downloads, it won't capture single asset downloads because jobs are not created.
    – josedbaez
    Jul 8, 2021 at 9:53

1 Answer 1

0

Asset downloads are logged as an entry in reporting log (event asset.download.completed), these are not stored on the Asset entity so you can't target that operation via triggers.

What you could do is have an external integration (e.g. timered function) that queries for downloads via Audit endpoint (https://docs.stylelabs.com/content/4.0.x/integrations/rest-api/audit/endpoints.html) and then you process as needed.

e.g. /api/audit/business/query?logType=reportingeventslog&fullText=asset.download.completed&from=2021-06-21T08:00&take=0

Note: I'm not sure if ALL downloads trigger this event (e.g. mass downloads via UI or downloads via API)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.