Route:before - opening file on frontend

Hi everyone,

is it possible to access the file Object (and make changes to it), when someone is opening a file on the frontend via a Link:

<a href="<?= $file->url(); ?>" target="_blank" /><?= $file->filename(); ?></a>

I tried using route:before, but it seems it does not access the router when opening the file URL? I could use JS to add an EventListener for clicking the Link and make an ajaxCall to access the filedata, but I wanted to know if I can avoid using ajax.

Thanks for the help in advance.