Download document and save the metadata

Hi All,

          My requirement is when I click on the download document link. I also need store some meta data in DB.

Metadata like who downloaded the document, time, document name, process variables etc. On click of the document download link two action should to be performed. 

1) Document should be downloaded.

2) Data should persisted in DB.

What should be my design approach.       

  Discussion posts and replies are publicly visible