How to trigger a cloud code function when user try to download a file?

When someone tries to download a file, I want to check something before he can download it. (assuming he has the direct download link)

How can I do that?

In php I found something that when you go to the download link, it runs a code and then download will start.

I believe currently its not possible.

I think I was looking for that functionality in past and came to same conclusion - it is not possible. At the end I did not need it, but just a quick solution for you could be…

If you implement additional class to keep list of files in the database as it is described in afterSaveFile trigger AND you are sure that everyone that wants to download the file will first look for the file through that additional class, then you could use find trigger to somehow assume that the user is going for that file.

Thank you.
so, then I’ll use before find trigger for now.