Alexey
Alexey

Reputation: 301

How to execute custom action in Alfresco before download a file?

I want to store in the repository an unchanged file, but change its content on dowloading due to user's role.

To do this I just created my own action that changes content of the file, but found that Alfresco does not provide an appropriate rule to be executed on file downloading.

My action must execute on download using API (link) and using CIFS or WebDAV (copying from folder), so I have to use a rules engine to execute action.

How can I realize this?

Upvotes: 0

Views: 1251

Answers (1)

skuro
skuro

Reputation: 13514

While I can't think of a solution that preserves the dataflow you describe, especially since file server interfaces are involved, I would advise you not to transform the content upon user request, as it would require online (blocking) computations upon each and every user download. I also assume that the results of such transformations are "static" for a given role.

I would solve your use case by:

  • creating an action that generates all the needed versions of the document

  • such action should also set permissions accordingly, so that ReadPermission is granted only to the target role

  • setup an inbound rule that triggers the action on all incoming documents

  • (optionally) creates and setup a similar action/rule pair to cleanup all the renditions upon content deletion

This way whichever user or role accesses the given folder will be presented only content in the form he's expecting to have.

Upvotes: 2

Related Questions