Flag a node after click on the link
If you're using the private file system, you can make use of hook_file_download, it is normally used for granting access but I don't see why not you can use it for flagging stuff.

See an example of this in Example of hook_file_download

If you're using the public one, it will be way trickier, you're going to need to wrap the download link to react with your custom code, this could be done by replacing the download link like the Public Download Count module does, or providing your own hook_menu callback that is called via ajax to flag the content, but then you depend on whether the user has js enabled or not.