Is it possible to combine an antivirus checker with 12 attachments on Data Services side? (i.e. before saving attachments check …)
Would it be different for attachments in reference mode (detached) and embedded mode?
Attachments in reference and embedded mode have different handling because the the embedded attachments are handled completely on the client side and there is no data services code to even detect them.
For this reason, you need to use DocumentBeforeCreateEvent and DocumentBeforeUpdateEvent to detect that the document has embedded attachments and then use the payload of events to perform virus checks.
For attachments in the reference mode, you can use AttachmentBeforeCreateEvent event during the attachment creation. The event has an attachment in the payload therefore it will be easier to use.
Listeners to the mentioned events can throw exceptions in case the attachment does not pass your security threshold. Thrown exception will rollback the current transaction and this will prevent saving of document or attachment.
This answer is valid for data services 33.0.0+
Hi @tomas-thin-gale,
Does data-service support virus scanner for attachment upload? or projects have to implement by themself? Thanks!
DS has created example how to do virus scanning in our example module. We cannot include it in our regular code base because it is based on technology (recommended by security partners) which requires standalone service. Having this would complicate setup for projects that do not require virus scanning. I would recommend for you to use this example and setup your own scanning based on it.
Hi @tomas-thin-gale ,
Thanks for your info, do you know where I can find this example?
Unfortunately, I cannot paste links in here, but examples can be found in our git repository in the examples directory. Alternatively, you can download dataservices/examples/examples-extending-server/36.3.1/ library from artifactory.
Virus check example is documented in read.me file in both cases.
Hi @tomas-thin-gale
Thank you, I’ll take a look on it and give it a try.